Re: Reversing the lines in a file[speed, stack overflow}
Re: Reversing the lines in a file[speed, stack overflow}
- Subject: Re: Reversing the lines in a file[speed, stack overflow}
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 11 May 2002 07:55:46 -0700
- Resent-date: Sat, 11 May 2002 08:38:16 -0700
- Resent-from: Paul Berkowitz <email@hidden>
- Resent-message-id: <B9027F02.26AA1¾email@hidden>
- Resent-to: Applescript-Users <email@hidden>
There is, though. It's probably extremely large, but there's a limit. I
realize I didn't have to set the chunks at 30,000, but I don't know how big
they should be so I chose 30K arbitrarily. I guess I should experiment to
find out. But when I tried to read a huge MBOX file, it couldn't do it. Not
"Stack overflow", but "Out of memory": and that's in OS X which doesn't have
application memory limitations. It was an AS memory limit for reading files
(not for string variables, which doesn't seem to have any). Reading in a
chunk at a time and concatenating to the agglomerated string works fine, and
very fast. It was a 129 MB file, as I recall. Maybe the limit is 32 MB? It's
worth trying to find out, I guess. If you say reading a 6 MB file works OK,
then my 30K is a little silly, I suppose.
--
Paul Berkowitz
On 5/11/02 7:40 AM, "Paul Skinner" <email@hidden> wrote:
>
What's wrong with just...
>
>
read file "Dalai:Users:paulskin:Desktop:1024000Line6MBDocument"
>
>
Maybe you were thinking about the text to list conversion limit. I don't
>
think that there's a limit to the data the read file command can get.
>
>
On Friday, May 10, 2002, at 06:19 PM, Paul Berkowitz wrote:
>
>
> On 5/10/02 10:30 AM, "Paul Skinner" <email@hidden> wrote:
>
>
>
>> On Friday, May 10, 2002, at 12:02 PM, Cornwall wrote:
>
>>
>
>>> paragraphs of (read theFil)
>
>>
>
>> When fed a really big hunk of text, this returns a list greater than AS
>
>> allows as the result of a single command.
>
>>
>
>> Somehow the 'read as list' gets around this limit. Apparently being an
>
>> OSAX lets you flaunt the rules.
>
>
>
> Here's my contribution to this discussion. It's awfully simple, so I
>
> must be
>
> the 4000th person to come up with it, I imagine. There's no limit
>
> whatsoever
>
> that I can discover. It even read a 100+ MB (that's MB, not KB) MBOX
>
> file
>
> containing large encoded email attachments.
>
>
>
>
>
> on ReadPartials(fileRef)
>
>
>
> local b, y, r, textClump
>
>
>
> set b to 1
>
> set y to 30000
>
>
>
> set r to ""
>
>
>
> set finished to false
>
>
>
> repeat until finished
>
>
>
> try
>
> set textClump to read fileRef from b to y
>
> set r to r & textClump
>
> on error -- last text clump
>
> set textClump to read fileRef from b to eof
>
> set r to r & textClump
>
> set finished to true
>
> end try
>
>
>
> set {b, y} to {b + 30000, y + 30000}
>
>
>
> end repeat
>
>
>
> return r
>
>
>
> end ReadPartials
>
>
>
>
>
>
>
> --
>
> Paul Berkowitz
>
> _______________________________________________
>
> applescript-users mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/applescript-users
>
> Do not post admin requests to the list. They will be ignored.
>
>
>
>
>
--
>
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.