Out of memory while reading excel file
eryk sun
eryksun at gmail.com
Fri May 12 16:44:50 EDT 2017
On Fri, May 12, 2017 at 8:03 PM, Peter Otten <__peter__ at web.de> wrote:
> I don't have a Windows system to test, but doesn't that mean that on Windows
>
> with open("tmp.csv", "w") as f:
> csv.writer(f).writerows([["one"], ["two"]])
> with open("tmp.csv", "rb") as f:
> print(f.read())
>
> would produce
>
> b"one\r\r\ntwo\r\r\n"
>
> ? How is that avoided?
Python 3 doesn't use the platform's standard I/O implementation.
However, it tries to be consistent with the platform by using
os.linesep as the default for translating newlines. That's not
necessarily compatible with the csv module, so it requires disabling
newline translation by passing newline="" to open(). Otherwise it does
cause the problem that you suppose it would, which is documented:
https://docs.python.org/3/library/csv.html#csv.writer
More information about the Python-list
mailing list