Re: parsing a large text file
Re: parsing a large text file
- Subject: Re: parsing a large text file
- From: Adam Bell <email@hidden>
- Date: Thu, 06 Jul 2006 20:04:44 -0300
- Comment:
Title: Re: parsing a large text file
At 1:52 PM -0600 7/6/06, email@hidden wrote:
I need help parsing a large text
file.
I need to examine the file one line at a time.
I make changes to it and then write it back out as a text file.
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.
I can read the first line with:
set file_data to (read datafileref as {text} until return)
But how do I read the next line? ... and the next, etc.,
etc.?
The trick with very large files is to take advantage of the
parameters
supported by the Scripting Additions' "Read"
statement:
function syntax
set theResult to read anything ¬
from double integer ¬
for double integer ¬
to double integer ¬
before string ¬
until string ¬
using delimiter string ¬
using delimiters {string, ...} ¬
as type class
Parameter
Required
Type
Description
direct parameter
required
anything
the file reference number, alias, or file reference of the file to
read
as
optional
type class
the form in which to read and return data
before
optional
string
or read up to but not including this character
for
optional
double integer
the number of bytes to read from current position; if omitted, read
until the end of the file
from
optional
double integer
starting from this position; if omitted, start at last position read
from
to
optional
double integer
or stop at this position
until
optional
string
or read up to and including this character
--
DOS
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
>esscable.net
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:
This email sent to email@hidden