Re: Need some help extracting records from flat file

new topic     » goto parent     » topic index » view thread      » older message » newer message

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
----------

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu