Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, juanex, Grant), 1,018 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Problem: Read line from file and tokenize content #216856
07/19/08 08:27
07/19/08 08:27
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi,

I'm searching for a good way to read the content of a file line by line and then tokenize the content of each line.

Let's say I have a text file with the following content:

row1;sometext;0;0;1;0;moretext;
row2;alsotext;1;1;0;1;againtext;
row3;textagain;1;0;1;0;moreblabla;

Now I'd like to read each line, separate its content to store it in a multi array, for example:

myarray[0][0] = row1
myarray[0][1] = sometext
myarray[0][2] = 0
...
myarray[1][0] = row2
myarray[1][1] = alsotext

and so on.

Do I have to use file_str_read first to read the whole line and then something like a combi of str_stri,str_len and str_trunc for tokenizing the line ??? I think there must be
a better way ?!?

If I'd use file_str_readto with delimiter ";" how would I know when the next line starts?

Can somebody help me?

Best regards,
Pegamode.

Re: Problem: Read line from file and tokenize content [Re: pegamode] #216903
07/19/08 17:48
07/19/08 17:48
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
maby you can use file find file_find


"empty"
Re: Problem: Read line from file and tokenize content [Re: flits] #216914
07/19/08 20:26
07/19/08 20:26
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hmmm ... with file_find I could maybe get rid of reading the content into an array, because I could directly access the needed data and save it into my struct, but I still need to read the rest of the line and tokenize it.

I don't know how I could do that with file_find.

Re: Problem: Read line from file and tokenize content [Re: pegamode] #217001
07/20/08 17:52
07/20/08 17:52
Joined: Aug 2005
Posts: 238
Caermundh Offline
Member
Caermundh  Offline
Member

Joined: Aug 2005
Posts: 238
you could try:

row1,sometext,0,0,1,0,moretext,*
row2,alsotext,1,1,0,1,againtext,*
row3,textagain,1,0,1,0,moreblabla,*

then use file_str_read(). it will read off "row1" the first time, "sometext" on the next read, etc. Then you just watch for "*" to know that your at the end of a line.

Re: Problem: Read line from file and tokenize content [Re: Caermundh] #217090
07/21/08 10:05
07/21/08 10:05
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi Caermundh,

thanks for your answer.

I had the same idea yesterday and it works fine so far.

Would be great if Conitec would add some functions to directly work with csv files or in general to tokenize strings in a better way.

Best regards,
Pegamode.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1