read csv error question

Vincent Davis vincent at vincentdavis.net
Mon Feb 23 19:02:31 EST 2009


Thanks for the help the "U" was what I needed. I was reading the
documentation here.http://docs.python.org/library/csv.html
but I could not find the term universal-newline mode, In fact where do you
find "U" I have not read it word for word but it is not obvious to me. I do
even see anything about "rb" but I might just be really blind.

Thanks again

Vincent Davis



On Mon, Feb 23, 2009 at 4:52 PM, Benjamin Kaplan
<benjamin.kaplan at case.edu>wrote:

>
>
> On Mon, Feb 23, 2009 at 6:43 PM, MRAB <google at mrabarnett.plus.com> wrote:
>
>> Vincent Davis wrote:
>>
>>> I am trying to read a csv file from excel on a mac. I get the following
>>> error.
>>> SystemExit: file some.csv, line 1: new-line character seen in unquoted
>>> field - do you need to open the file in universal-newline mode?
>>> I was using the example code
>>> import csv, sys
>>>
>>> reader = csv.reader(open('/Volumes/vincentdavis
>>> 2/match/data/matchdata2008.csv', "rb"))
>>> try:
>>>    for row in reader:
>>>        print row
>>> except csv.Error, e:
>>>    sys.exit('file %s, line %d: %s' % (filename, reader.line_num, e))
>>>
>>> I think this has to do with the end of line character but I am unsure how
>>> to fix it. I don't what to change the actual csv file I would like to fix
>>> the code.
>>>
>>>  FYI, Mac line endings are carriage-return '\r', Linux line endings are
>> linefeed '\n', and Windows endings are _both_ '\r\n'.
>>
>
> Just to clarify, only the old Mac OSes (1-9) use carriage returns. OS X is
> Unix-based so it uses line feeds.
>
>
>
>>
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090223/d5f1c6a7/attachment.html>


More information about the Python-list mailing list