Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Read numbers from a .csv text file

Author
Message
BobH0905
19
Years of Service
User Offline
Joined: 3rd Feb 2005
Location: Portsmouth
Posted: 10th Sep 2014 13:47
I'm trying to populate an array from a .txt file
Array is arrayname[3,4]
I want the text file to be

1,2,3,4
5,6,7,8
9,10,11,12

But I can't find how to read the individual elements of the (effectively csv) text file
(the numbers won't be 1-12, I've just used those because it's easier to show what I mean)
My only other option would be to have a text file like this
1
2
3
4
####
5
6
7
8
####
9
10
11
12
####
and readline()
#### is simply a separator to make it easier to see the file breakdown when viewing it in a text editor.

Is there a way of reading the separate elements using the .csv format, because if there is I can't work it out.
I'll always know exactly how many entries are in the text file, but not what the values are.
Any help, including telling me that it isn't possible, would be gratefully appreciated.
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 10th Sep 2014 16:23 Edited at: 10th Sep 2014 16:29
For the first format, I would suggest a combination of Readline() to pull a while line of values in at once and GetStringToken() to split it up;

(headcoded so may contain typos)

Edit: Typo
BobH0905
19
Years of Service
User Offline
Joined: 3rd Feb 2005
Location: Portsmouth
Posted: 10th Sep 2014 16:55
THANK YOU. I've been racking my brains trying to work this one out. Trouble was, I didn't know about the GETSTRINGTOKEN() command.
I'll get there eventually, gradually learning all the commands, but I might forget the early ones before I get to the end.
Once again, thank you.

Login to post a reply

Server time is: 2024-11-25 09:31:22
Your offset time is: 2024-11-25 09:31:22