[issue4847] csv fails when file is opened in binary mode

2009-01-05 Thread jaywalker
jaywalker jaywal...@yahoo.com added the comment: In an unlikely scenario: say one of the fields has an embedded \r. For instance blahblah\r is the value of the first column. Now open this file in text mode. What happens to this '\r' even before csv.reader sees it? If it remains intact

[issue4847] csv fails when file is opened in binary mode

2009-01-05 Thread jaywalker
jaywalker jaywal...@yahoo.com added the comment: make it '\r\n', if you want. Such files can be easily generated on windows text editors, or even linux ones nowadays. Upon reading, if the file is opened in text mode, this will probably be converted to \n even on linux by python (I may

[issue4847] csv fails when file is opened in binary mode

2009-01-05 Thread jaywalker
jaywalker jaywal...@yahoo.com added the comment: I think what you suggest makes most sense. Thanks. - Original Message From: Antoine Pitrou rep...@bugs.python.org To: jaywal...@yahoo.com Sent: Monday, January 5, 2009 12:47:21 PM Subject: [issue4847] csv fails when file is opened

[issue4847] csv fails when file is opened in binary mode

2009-01-05 Thread jaywalker
New submission from jaywalker jaywal...@yahoo.com: The following code from the documentation fails: # import csv reader = csv.reader(open(eggs.csv, rb)) for row in reader: print(row) # The output is: Traceback (most recent call last): File stdin, line 1