On Wed, Dec 2, 2009 at 3:14 PM, J <dreadpiratej...@gmail.com> wrote:
> Something that came up in class...
>
> when you are pulling data from a file using f.next(), the file is read
> one line at a time.
>
> What was explained to us is that Python iterates the file based on a
> carriage return as the delimiter.
> But what if you have a file that has one line of text, but that one
> line has 16,000 items that are comma delimited?
>
> Is there a way to read the file, one item at a time, delimited by
> commas WITHOUT having to read all 16,000 items from that one line,
> then split them out into a list or dictionary??

If f is a file object, f.read(1) will get the next byte of the file.
Get single-character strings that way until you arrive at a ",", then
concatenate what you have received before that.

-- 
André Engels, andreeng...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to