Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parsing a large text file



On Jul 7, 2006, at 12:53 PM, DOS wrote:

In the past I have put it all into one variable with:

set datafileref to (choose file with prompt "Choose the file:")
set file_data to (read datafileref as {text} using delimiter return)

But it doesn't work on a 32MB text file.


What version of AppleScript do you have? Did you mean 32mb or 32k? Older version of AppleScript had a 32k limit. If you're reading 32 _MB_ then you're reading a HUGE file by AS standards, and it will take a VERY long time to parse.


That being said, most of the later versions of AppleScript will handle files larger than 32k, I've read in over 200k before (takes a while to parse that, I'll tell you). You can get the text into a variable and access the lines with

repeat with myLine in paragraphs of theFile
(*do your parsing of the line*)
end repeat

Kevin
--
Insist on yourself; never imitate... Every great man is unique.
Ralph Waldo Emerson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.