Re: Parsing Large Text Files
Re: Parsing Large Text Files
- Subject: Re: Parsing Large Text Files
- From: Bruce Robertson <email@hidden>
- Date: Fri, 02 May 2008 08:21:36 -0700
Yes, that't nice, gets down to about 22MB/minute.
The perl script processes at about 800MB/minute by my rough test.
> Bruce Robertson wrote on Thu, 01 May 2008 21:37:31 -0700:
>
>> Mark's perl script is way fast, here is what I was attempting in applecript.
>
> Perl's obviously the way to go in your case, but I can't resist tinkering
> with the AS performance. :) This uses File Read/Write instead of the
> shell script, 'set' instead of 'copy', referenced list variables, and a
> more efficient way of inserting returns into the reversed text:
>
> set f to read (choose file)
> set astid to AppleScript's text item delimiters
> set AppleScript's text item delimiters to ">"
> set f to text items of f
> set AppleScript's text item delimiters to ""
>
> set fRef to (open for access file ((path to desktop as Unicode text) &
> "new.txt") with write permission)
> try
> set eof fRef to 0
> set t to current date -- Equivalent timing start point.
> repeat with num from 1 to (count f)
> set thisOne to item num of my f
> if ((count thisOne) > 0) then
> set thisOne to paragraphs of thisOne
> set newtext to ">" & item 1 of my thisOne
> try
> set otherLines to rest of my thisOne
> set newtext to newtext & return & reverseMe(otherLines as text)
> on error
> -- beep
> end try
> write newtext as string to fRef
> end if
> end repeat
> end try
> close access fRef
> set AppleScript's text item delimiters to astid
> set f to ""
> beep
> display dialog ((current date) - t)
>
> on reverseMe(what)
> script o
> property l : (reverse of (characters of what))
> end script
>
> set len to (count what)
> repeat with i from 50 to len by 50
> set item i of o's l to item i of o's l & return
> end repeat
> if (i is not len) then set item len of o's l to item len of o's l & return
> return o's l as text
> end reverseMe
>
>
> NG
>
> _______________________________________________
> 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
>
_______________________________________________
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