Re: Reading text files line-by-line (dead link from archive)
Re: Reading text files line-by-line (dead link from archive)
- Subject: Re: Reading text files line-by-line (dead link from archive)
- From: Oleg Kibirev <email@hidden>
- Date: Tue, 28 Aug 2007 12:51:50 -0700
You can just use plain old fdopen and fgets if your lines are of a
reasonable size. Otherwise you can mmap a few megs of the file at a
time and use memchr(ptr, '\n', len) to look for newlines in the
mapped area.
On Aug 28, 2007, at 12:18 PM, Daniel Dickison wrote:
On Aug 28, 2007, at 3:09 PM, Scott Thompson wrote:
Do you need to handle ASCII text files, UTF-32, UTF-16, UTF-8, or
some combination of all of them?
I believe it's only ASCII, but the source of the data in question
is not particularly clear about that. It _does_ have to work with
both Unix-style and Windows-style line endings.
Right now I'm using NSScanner with a completely in-memory NSString,
but the code has to scale well for very large text files (it's for
text-based eye tracking data files) -- which might not actually be
a problem, but seems like it would. Ok, I admit: I'm committing
premature optimization.
Daniel
_______________________________________________
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:
40oracle.com
This email sent to email@hidden
_______________________________________________
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