Sign in to follow this  
Followers 0
ProductOfMomAndDad

read values from file into 2 dimensional array

3 posts in this topic

Hi there!

Can someone tell me how i can read values from a file into a 2 dimensional array?

I have a text file with records like:

12, 50, 676, 2323

123,453,6756,86

344,4545,6666,5

With _FileCountLines i can determine the number of records and store it in e.g. $totalRecords.

That works fine.

Now i'd like to read the values into an array.

Something with $recordsArray[$totalRecords][4]

But when i use _FileReadToArray and then use MsgBox(0,"",$recordsArray[1][1]) i get an error message about wrong subscripts and the program terminates.

When i use MsgBox(0,"",$recordsArray[1]) i get as output: 12,50,676,2323 meaning the whole record has been read into one variable instead of in the four variables [1][1] and [1][2] and [1][3] and [1][4]

Hope someone can help me.

Bye all!

I am not real smart, but i can lift heavy things...

Share this post


Link to post
Share on other sites



Hi there!

Can someone tell me how i can read values from a file into a 2 dimensional array?

I have a text file with records like:

12, 50, 676, 2323

123,453,6756,86

344,4545,6666,5

With _FileCountLines i can determine the number of records and store it in e.g. $totalRecords.

That works fine.

Now i'd like to read the values into an array.

Something with $recordsArray[$totalRecords][4]

But when i use _FileReadToArray and then use MsgBox(0,"",$recordsArray[1][1]) i get an error message about wrong subscripts and the program terminates.

When i use MsgBox(0,"",$recordsArray[1]) i get as output: 12,50,676,2323 meaning the whole record has been read into one variable instead of in the four variables [1][1] and [1][2] and [1][3] and [1][4]

Hope someone can help me.

Bye all!

I am not real smart, but i can lift heavy things...

you'll have to stringsplit on the comma to seperate the values


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

you'll have to stringsplit on the comma to seperate the values

That's FAST!

Thank you for your help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0