Re: Parsing Large Text Files
Re: Parsing Large Text Files
- Subject: Re: Parsing Large Text Files
- From: Bruce Robertson <email@hidden>
- Date: Thu, 01 May 2008 21:37:31 -0700
> On Thu, May 1, 2008 at 6:54 PM, Bruce Robertson <email@hidden> wrote:
>> Posting for a friend, who needs to parse 80MB protein data files.
>
> That is not in any way a good problem for solving with AppleScript.
> Does this friend have a particular reason for wanting to do so? Almost
> any other randomly-chosen programming language will do the job more
> easily and efficiently.
>
> --
> Mark J. Reed <email@hidden>
Mark's perl script is way fast, here is what I was attempting in applecript.
Performance was about 1MB/minute.
set f to read (choose file)
set AppleScript's text item delimiters to ">"
set f to text items of f
set AppleScript's text item delimiters to ""
do shell script "echo '' > ~/desktop/new.txt"
set t to current date
repeat with num from 1 to count of f
get item num of f
copy result to thisOne
if thisOne "" then
set thisOne to paragraphs of thisOne
set line1 to item 1 of thisOne
set newtext to ">" & item 1 of thisOne
try
set otherLines to items 2 thru -1 of thisOne
set newtext to newtext & return & reverseMe(otherLines as text)
on error
-- beep
end try
do shell script "echo " & quoted form of newtext & " >>
~/desktop/new.txt"
end if
end repeat
length of newtext
set f to ""
beep
display dialog ((current date) - t)
on reverseMe(what)
copy (reverse of (characters of what)) to what
break(what as text)
return result
end reverseMe
on break(what)
set newChunk to ""
set L to length of what
repeat with num from 1 to L by 50
set N to num + 49
if N > L then set N to L
set newChunk to newChunk & return & (text num thru N of what)
end repeat
return text 2 thru -1 of newChunk
end break
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden