473,624 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open a text file and into an array ??

Can someoneillustra te how I would open a text file that looks something
similar to this:
namea,8888,1234 .99
nameb,8887,1242 .50

and then after opening that file read each one of the values into an
array...namea and 8888 and 1234.99 would be three arrays

thanks
Feb 12 '06 #1
3 1608
Jason wrote:
Can someoneillustra te how I would open a text file that looks something
similar to this:
namea,8888,123 4.99
nameb,8887,124 2.50

and then after opening that file read each one of the values into an
array...name a and 8888 and 1234.99 would be three arrays

thanks

Actually, it would be one array, with three indeces.

dim sline as string = lineinput(filep ointer)
dim aline as array = split(sline,"," )
Then you would have these values:
aline(0) = namea
aline(1) = 8888
aline(2) = 1234.99

Tom

Feb 12 '06 #2

"tomb" <to**@technetce nter.com> wrote in message news:NJ******** ********@bignew s8.bellsouth.ne t...
Jason wrote:

Can someoneillustra te how I would open a text file that looks something
similar to this:
namea,8888,1234 .99
nameb,8887,1242 .50

and then after opening that file read each one of the values into an
array...namea and 8888 and 1234.99 would be three arrays

thanks
Actually, it would be one array, with three indeces.

dim sline as string = lineinput(filep ointer)
dim aline as array = split(sline,"," )
Then you would have these values:
aline(0) = namea
aline(1) = 8888
aline(2) = 1234.99

Tom
How would I actually open the file?....and then get that file to seperate into the array. Lets say the file name is test.txt
for example I want to store namea as strUser 8888 as dblaccess and 1234.99 as dblaccount

so I would like it to fill an array like this...
info(0).strUser = "namea"
info(0).dblacce ss = 8888
info(0).dblacco unt = 1234.99

and
info(1).strUser = "nameb"
info(1).dblacce ss = 8887
info(1).dblacco unt = 1242.50

and so on until the end of file.
Feb 13 '06 #3
Jason wrote:


"tomb" <to**@technetce nter.com <mailto:to**@te chnetcenter.com >>
wrote in message news:NJ******** ********@bignew s8.bellsouth.ne t...
Jason wrote:
Can someoneillustra te how I would open a text file that looks something
similar to this:
namea,8888,12 34.99
nameb,8887,12 42.50

and then after opening that file read each one of the values into an
array...nam ea and 8888 and 1234.99 would be three arrays

thanks

Actually, it would be one array, with three indeces.

dim sline as string = lineinput(filep ointer)
dim aline as array = split(sline,"," )
Then you would have these values:
aline(0) = namea
aline(1) = 8888
aline(2) = 1234.99

Tom

How would I actually open the file?....and then get that file to
seperate into the array. Lets say the file name is test.txt

for example I want to store namea as strUser 8888 as dblaccess
and 1234.99 as dblaccount

so I would like it to fill an array like this...
info(0).strUser = "namea"
info(0).dblacce ss = 8888
info(0).dblacco unt = 1234.99

and
info(1).strUser = "nameb"
info(1).dblacce ss = 8887
info(1).dblacco unt = 1242.50

and so on until the end of file.

Why do you need it in an array?
I ask only because in order to dimension the array at the start, you
would need to know how many lines of data you have. While you could
keep redimensioning the array with every line you read, that would be a
serious resource hog. You might want to consider putting the data in a
datatable and working with it that way. Or just read and process one
line at a time, as my original illustration would do.

T
Feb 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3538
by: BadOmen | last post by:
I have a text file that I want to save from my program. But I don't want to save the empty lines. I want to delete everything after the last character, Is that possible? Then when I read the text file i don't want to read empty lines(If the user as edit the file in notpad..), sense it makes commas at all new lines and then split the text at every comma in to an array. The array will contain empty "slot's" if there is a lot of commas in a...
4
1588
by: Nicolas | last post by:
How do I open a file which is saves into the database as byte() So far, I got this and it's working Dim myDoc as Byte() myDoc = CType(dbDataRow("Document"), Byte()) From there how do I open this so the user can review this file. Thank for the help.
2
1937
by: CopynPaste | last post by:
Hi, I wrote a VB.net program that import a text file, which I will parse and place into arrays. My question is how to open an existing Word file without the Dialog Box that has a 4x10 table and place the array into the table ? Thank you for any assistance. CopynPaste
4
3569
by: Stupid48 | last post by:
I'm trying to do a simple task but can't seem to find a solution. How do I read lines from a text file backwards. i.e. I want to select the last 20 lines of a text file and display them in order starting with the last line first..... Any assistance would be greatly appreciated.... Thanks, Chris
10
6095
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the code below which when executed generates the following error message: 'There is already an open datareader with this command which must be closed first' Private Sub MainMenu_Load(ByVal sender As System.Object, ByVal e As
2
1855
by: MikeJ | last post by:
Hi all.... I need to work with large text files....i know there is a lot of ways under net to work with them.... i want speed, High Percentage of correctness so i was thinking ...but not sure the best way to handle text files for parsing into reports, or into SqlDatabase or Where Ever else my question is;
3
1539
by: cmdolcet69 | last post by:
How do i parse a text file with data value in it? I have a series of values that are sepereated by commas. the file holds around 3700 values and all these values need to be parsed out and put into an array to be used.
2
2774
by: Kosmos | last post by:
I am opening the following connections as such although I am only referring to the first connection for this question: Dim con1 As ADODB.Connection Dim con2 As ADODB.Connection Dim recSet1 As ADODB.Recordset Dim recSet2 As ADODB.Recordset Set con1 = CurrentProject.Connection Set con2 = CurrentProject.Connection Set recSet1 = New ADODB.Recordset Set recSet2 = New ADODB.Recordset
0
10750
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
8238
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8624
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7164
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.