Re: Read lines from very large text file
Re: Read lines from very large text file
- Subject: Re: Read lines from very large text file
- From: Kenneth Bruno II <email@hidden>
- Date: Mon, 2 Feb 2009 21:56:41 -0500
On Feb 2, 2009, at 9:29 PM, Peter Duniho wrote:
On Feb 2, 2009, at 6:02 PM, Seth Willits wrote:
Before opening the file, either determine, guess, or be told what
the encoding is. With that encoding, convert your delimiter string
into raw bytes, then do byte-for-byte comparison on the file to
find occurrences of that delimiter.
Is there not a Cocoa class that handles character encoding and line-
based reading from files, streams, etc.? And an equivalent one for
writing?
That seems like an odd omission for a comprehensive framework.
NSString handles such things, the only thing I'm not sure is how it
will handle a truly large multi-gigabyte text file (not that anyone is
likely to have such a beast). With a gigantic file like that you'd
probably have to switch to using something like NSFileHandle, read
chunks, and then parse those chunks. However, I'd expect NSString to
be handle reasonably large files in a sane manner.
As far as string manipulation, I'd take a look at the information
straight from the horse's mouth:
<http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/introStrings.html
>
There are sections dedicated to reading strings from files and
paragraphs and line breaks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden