1. Parsing question...
- Posted by LEVIATHAN <leviathan at USWEST.NET> Aug 26, 2000
- 490 views
Heya all! I'm trying to do a program, and I'm trying to parse a tab-separated file. So that I don't reinvent the wheel on myself, has there been any libraries/includes that aid in parsing comma-separated/tab- separated files? TIA, Blessed Be! --"LEVIATHAN"
2. Re: Parsing question...
- Posted by Kat <gertie at PELL.NET> Aug 26, 2000
- 473 views
On 26 Aug 2000, at 9:17, LEVIATHAN wrote: > Heya all! > > I'm trying to do a program, and I'm trying to parse a tab-separated > file. > > So that I don't reinvent the wheel on myself, has there been any > libraries/includes that aid in parsing comma-separated/tab- > separated files? Can you give a short example? Kat
3. Re: Parsing question...
- Posted by LEVIATHAN <leviathan at USWEST.NET> Aug 26, 2000
- 482 views
- Last edited Aug 27, 2000
> Can you give a short example? > Heh, I knew I was probly gonna havta do that :) example: health 25 5 14 14 0.0 1.0 0.0 0.75 healthbar 285 239 value 2 1.0 0.0 0.0 1.0 gfx/2d/colorbar.tga 0.2 0 Blessed Be! --"LEVIATHAN
4. Re: Parsing question...
- Posted by hisshadow <hisshadow at COMPAQNET.CO.UK> Aug 27, 2000
- 529 views
hi leviathan, sorry but i think your message must be for someone else. bye from your electronic friend mark ----- Original Message ----- From: LEVIATHAN <leviathan at USWEST.NET> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Sunday, August 27, 2000 5:07 AM Subject: Re: Parsing question... > > Can you give a short example? > > > > Heh, I knew I was probly gonna havta do that :) > > example: > health 25 5 14 14 0.0 1.0 0.0 0.75 > healthbar 285 239 value 2 1.0 0.0 0.0 1.0 gfx/2d/colorbar.tga > 0.2 0 > > Blessed Be! --"LEVIATHAN
5. Re: Parsing question...
- Posted by Kat <gertie at PELL.NET> Aug 27, 2000
- 470 views
On 26 Aug 2000, at 21:07, LEVIATHAN wrote: > > Can you give a short example? > > > > Heh, I knew I was probly gonna havta do that :) > > example: > health 25 5 14 14 0.0 1.0 0.0 0.75 > healthbar 285 239 value 2 1.0 0.0 0.0 1.0 > gfx/2d/colorbar.tga 0.2 0 You could look at strtok.e with a readme which i just sent to RDS for the archives. You can use it to find/replace/delete tokens in a sequence/string. I don't know per your example how the users are separated in the data file, or if each user has their own file, and i can't see a tab char. Assuming each user has their own file, and each line is terminated by a ascii 10, then after reading the file into filedata, sequence healthline = gettok(filedata,1,10) sequence healthbarline = gettok(filedata,2,10) object healthline_valnum4 = gettok(healthline,4,TheAsciiForTab) = 14 If you put all the datum for all the users into one file, and read it as one sequence, and each user has an xml tag, such as <LEVIATHAN> , and you xml'd the rest of the data as well, then you could use getxml() to parse the data, altho i don't have a putxml() yet, since i didn't need one, sorry. So getxml(filedata,"LEVIATHAN","/",1) would return your data, and getxml(filedata,"Kat","/",0) would return {} since i don't have a data in your file. <LEVIATHAN> <health>25,5,14,14,0.0,1.0,0.0,0.75</health> <healthbar>285,239,value,2,1.0,0.0,0.0,1.0,gfx/2d/colorbar.tga 0.2,0<healthbar> </LEVIATHAN> (I used commas just so i'd have something to see there.) Then, yourhealth = getxml(yourdata,"health","/",1") {25,5,14,14,0.0,1.0,0.0,0.75} Or, if you parse(yourhealth,',') , it would be: {"25","5","14","14","0.0","1.0","0.0","0.75"} so you could do: energy = 5 sight = 8 seq yourhealthseq[energy] and get the "0.0" seq yourhealthseq[sight] and get the "0.75" Which is a fine scheme to avoid the error of getting "gfx/2d/colorbar.tga" into an integer, `course, there are other schemes. Kat