[REBOL] Thanks for the line delete
From: aroberts::swri::edu at: 19-Jul-2001 8:32
I was out for a week and didn't post a thanks to all who helped in solving my line reduction
problem. I appreciate the insight of everyone who made comments.
The best version goes to Larry Palmiter, whose version parses a 2.1 Meg file in approx
4 seconds! The closest to that was a version by Joe Neely, which was just shy of 60s.
Of course these numbers are wholly dependent on the computer and shouldn't be used as
a benchmark, but rather a general guideline.
I have included Larry's version, based upon his suggestions.
Regards,
Aaron
REBOL[
Title: "Removelines"
Date: 17-jul-2001
Note: {Removes the lines without buffering and uses port method}
]
input_file: to-file ask "Enter the source file name: "
output_file: ask "Enter the output file name: "
skip_amount: to-integer ask "Remove line after every X lines: "
out: make block! (size? input_file) / 50 ;preset approx. size of block
datafile: open/read/direct/lines input_file ;avoids buffering
while [x: copy/part datafile 1]
[append out x datafile: skip datafile skip_amount]
close datafile
out: head out
write/lines to-file output_file out