Skip Montanaro <skip.montan...@gmail.com> added the comment:

Looking at your sample file, it seems stranger than you first indicated. Your 
line terminator actually appears to be '\x07\r\n', not just '\x07'.  Opening 
your file in text mode will leave you with '\x07' as the last character of the 
last cell in each row. I've attached two files, bell.csv, which has just '\x07' 
as the line terminator, and lfmapper.py, which provides a class (suboptimally 
named LFMapper) which takes a file object opened in binary mode and optional 
line_terminator and encoding args, and performs the necessary slicing of the 
input bytes, decoding them and returning strings.

Unless Python grows a way for you to tell the open() function what string to 
use as the line terminator in text mode, I don't think your example is ever 
going to work without some sort of shim class.

----------
Added file: https://bugs.python.org/file48521/bell.csv

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37709>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to