1. Need some help extracting records from flat file
- Posted by csaik <chris.saik at comcast.net> Nov 16, 2005
- 434 views
- Last edited Nov 17, 2005
Hello everyone. I have a problem and am humbly requesting your help. I have a flat txt file that contains about 120k records. Each record resides on it's own line in the flat file, and each record has a fixed length of 325. I need to extract every 8th record (starting from the 1st... so 1,9,17,etc) from this file and place these records in another txt file. Can anyone assist me with creating the loop to accomplish this? I am certain that this is easy but my brain is fried. I would be very grateful. Thank you, Chris
2. Re: Need some help extracting records from flat file
- Posted by Patrick Barnes <mrtrick at gmail.com> Nov 16, 2005
- 414 views
- Last edited Nov 17, 2005
Well, you know how to open a file, and write to a file? atom fi, fo object line integer line_num fi = open("infile.txt","r") fo = open("outfile.txt","w") line_num = 0 line = gets(fi) while (sequence(line)) do if not remainder(line_num, 8) then puts(fo, line) end if line_num += 1 line = gets(fi) end while close(fi) close(fo) [UNTESTED, use at own risk] On 11/17/05, csaik <guest at rapideuphoria.com> wrote: > > > posted by: csaik <chris.saik at comcast.net> > > Hello everyone. I have a problem and am humbly requesting your help. > > I have a flat txt file that contains about 120k records. Each record res= ides on it's own line in the flat file, and each record has a fixed length = of 325. I need to extract every 8th record (starting from the 1st... so 1,= 9,17,etc) from this file and place these records in another txt file. > > Can anyone assist me with creating the loop to accomplish this? I am cer= tain that this is easy but my brain is fried. I would be very grateful. > > Thank you, > > Chris > > > > -- MrTrick ----------
3. Re: Need some help extracting records from flat file
- Posted by csaik <chris.saik at comcast.net> Nov 17, 2005
- 433 views
Thank you Patrick. This is exactly what I was looking for. I just registered Euphoria today. I really like the language.