[Python-bugs-list] [ python-Bugs-789519 ] CSV reader does not parse
Mac line endings
SourceForge.net
noreply at sourceforge.net
Fri Aug 15 20:02:58 EDT 2003
Bugs item #789519, was opened at 2003-08-15 16:16
Message generated for change (Settings changed) made by montanaro
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=789519&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Larry Meyn (lmeyn)
>Assigned to: Skip Montanaro (montanaro)
Summary: CSV reader does not parse Mac line endings
Initial Comment:
#Test code:
import csv
import traceback
class excel_mac(csv.Dialect):
delimiter = ','
quotechar = '"'
doublequote = True
skipinitialspace = False
lineterminator = '\r'
quoting = csv.QUOTE_MINIMAL
csv.register_dialect("excel_mac", excel_mac)
class excel_unix(csv.Dialect):
delimiter = ','
quotechar = '"'
doublequote = True
skipinitialspace = False
lineterminator = '\n'
quoting = csv.QUOTE_MINIMAL
csv.register_dialect("excel_unix", excel_unix)
testdata = range(10)
for dialect in ["excel","excel_unix","excel_mac"]:
try:
print '\n Testing dialect "%s"' % dialect
test = file('test.csv','w')
writer = csv.writer(test,dialect=dialect)
for i in range(3):
writer.writerow(testdata)
test.close()
test = file('test.csv','r')
reader = csv.reader(test,dialect=dialect)
for row in reader:
print row
except:
traceback.print_exc()
#Results
"""
Testing dialect "excel"
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
Testing dialect "excel_unix"
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
Testing dialect "excel_mac"
Traceback (most recent call last):
File "/Users/lmeyn/Desktop/testcsv.py", line 36, in ?
print row
Error: newline inside string
"""
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=789519&group_id=5470
More information about the Python-bugs-list
mailing list