Re: Long text file manipulation...
Re: Long text file manipulation...
Hi,
Christopher Stone gave me some very useful help with a similar problem.
Try the osax he suggested:
http://www.lazerware.com/FTP/RECommands.hqx
He also wrote this script (see below), hope this helps.
//Peter
set goFlag to false
set srcFldr to alias "Black Hole:Src Test:"
set destFldr to alias "Black Hole:Dest Test:"
tell application "Finder"
set theFiles to files of srcFldr
end tell
try
repeat with i from 1 to count of theFiles
set aFile to open for access (item i of theFiles) with write
permission
set t to read aFile
set t to REReplace t with "" pattern "^\\s+"
set t to REReplace t with "" pattern "-+\\r" separator "6"
set t to REReplace t with "\\t" pattern "\\r+" separator "6"
set eof of aFile to 0
write t to aFile
close access aFile
end repeat
set goFlag to true
on error errMsg number errNum
close access aFile
beep
display dialog errMsg & return & return & errNum
end try
if goFlag is true then
tell application "Finder"
move theFiles to destFldr with replacing
end tell
end if
-----------------------
>
I'm working on a project in which I need to manipulate large text files, one
>
line at a time. I've been looking for some sort of OSAX that can do this
>
because I cannot afford the memory and time requirements to read in lots of
>
big (2.5 MB) text files and then save them out, but have been unsuccessful.
>
>
Essentially, I just want to read the first line of the file and delete it from
>
the file and add another line to the bottom of the file.
>
>
Anybody have any ideas?
>
>
Thanks alot!
>
I'm working on a project in which I need to manipulate large text files, one
>
line at a time. I've been looking for some sort of OSAX that can do this
>
because I cannot afford the memory and time requirements to read in lots of
>
big (2.5 MB) text files and then save them out, but have been unsuccessful.
>
>
Essentially, I just want to read the first line of the file and delete it from
>
the file and add another line to the bottom of the file.
>
>
Anybody have any ideas?
>
>
Thanks alot!