[issue8387] use universal newline mode in csv module examples

2020-05-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Python 2.7 is no longer supported.

--
nosy: +serhiy.storchaka
resolution:  -> out of date
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2019-03-15 Thread Mark Lawrence


Change by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2014-06-26 Thread Mark Lawrence

Mark Lawrence added the comment:

@sfinnie can we please have a response to the question first asked by Antoine 
and repeated by Jessica, thanks.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2014-04-25 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
versions:  -Python 3.1, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2014-04-20 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Note that 'U' is a no-op under Python 3, it's just there for compatibility 
reasons; i.e. 'rU' is the same as 'r'.

Also, from a quick glance, the CSV parser in _csv.c looks newline-agnostic.

@sfinnie: can you explain which problems you encountered running the examples? 
Please also post the resulting exception tracebacks, if any.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2014-04-20 Thread Jessica McKellar

Jessica McKellar added the comment:

I realized that I typo'd 2 instead of 3 in 
http://bugs.python.org/issue8387#msg216888 which makes that message confusing. 
Here's a restatement of my findings:

* All of the Python 3 csv examples work in Python 3 on all platforms.
* The Python 2 binary-mode csv examples work in Python 2.7 on all platforms.
* The Python 2 binary-mode csv examples error out on Windows and OSX when run 
under Python 3. We could do nothing to address this, or, if we determine that 
there's no negative impact to removing the 'b', update the examples to 
accommodate readers who are running Python 2 examples using Python 3 for 
whatever reason.

Which does bring me to the same question as @pitrou, which is what data and 
code cause an error for @sfinnie on Python 2. :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2014-04-19 Thread Jessica McKellar

Jessica McKellar added the comment:

I ran some experiments to see what the state of the world is. I generated a 
test.csv by exporting a CSV file from Numbers on OSX. This generated a file 
with Windows-style \r\n-terminated lines. The attached test_csv.py tries to 
open this CSV file in binary and universal newlines modes. Here's what happens 
on various platforms

Python 3:
* Linux: both binary and universal work
* OSX: binary errors out, universal works
* Windows: binary errors out, universal works

In both cases, the error was:

$ python3 test_csv.py
Traceback (most recent call last):
  File test_csv.py, line 5, in module
for row in spamreader:
_csv.Error: iterator should return strings, not bytes (did you open the file in 
text mode?)

Python 2:
* Linux: both binary and universal work
* OSX: both binary and universal
* Windows: wasn't readily able to test

If I manually create a CSV file using TextEdit in plaintext mode on OSX, that 
produces a file with Mac-style \r-terminated lines. test_csv.py has the same 
results on this file on OSX (errors out in binary mode in Python 3).

--
nosy: +jesstess
Added file: http://bugs.python.org/file34981/test_csv.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2014-04-19 Thread Jessica McKellar

Changes by Jessica McKellar jesst...@mit.edu:


Added file: http://bugs.python.org/file34982/test.csv

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2014-04-19 Thread Jessica McKellar

Jessica McKellar added the comment:

All of the examples from https://docs.python.org/3/library/csv.html run without 
issue on OSX, though.

In summary, the Python 2 examples error out on OSX and switching them to use 
'U' instead of 'b' would fix this. I don't think any action needs to be taken 
for Python 3.

My one remaining question is about binary files on Windows. The Python 2 csv 
docs say If csvfile is a file object, it must be opened with the ‘b’ flag on 
platforms where that makes a difference. I don't readily have a Windows 
machine to play with this -- do binary CSV files exist, or can we eliminate 
the 'b' language entirely and just talk about 'U'?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2014-04-19 Thread Mark Lawrence

Mark Lawrence added the comment:

I think that it's complete nonsense to talk about binary csv files on Windows.  
They are just plain text files that can be manipulated with any old editor or a 
spreadsheet.

--
nosy: +BreamoreBoy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2014-04-19 Thread R. David Murray

R. David Murray added the comment:

The magic of newline='' in python3 is that it *preserves* the line end 
characters, which is the same thing binary mode does on windows.  The place 
that matters, as I remember it, is when there is a newline embedded inside a 
quoted string.  I don't remember *why* that matters, though :(.  But it had 
something to do with how the csv module processes the data internally.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2011-03-19 Thread Skip Montanaro

Changes by Skip Montanaro s...@pobox.com:


--
nosy:  -skip.montanaro

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2010-08-07 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

In the current 2.7 docs, files are opened with 'rb' or 'wb'.
In msg106210 of #1072404, RDM says The doc has been fixed;.
I am not sure if this refers a change in the open or just removal of reference 
to non-working delimiter option.
David?
Any opinion on this request?

--
assignee: georg.brandl - d...@python
nosy: +d...@python, r.david.murray, terry.reedy
stage:  - needs patch
versions:  -Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2010-08-07 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

The doc has been fixed refers to the fact that the lineterminator dialect 
option is now documented as applying only to writing, not to reading.

The docs could certainly be improved to discuss using universal newline mode.  
I'm not clear on whether or not there are disadvantages to using universal 
newline mode with the py2 version of the csv module, but I wouldn't be 
surprised if there are.  Perhaps Skip can comment on whether changing the 
examples to use rU would be a good idea or not.

Note that the situation for the py3k csv module is different, and it would be 
helpful if someone could test this issue there.  Though in truth we have no 
resources to support non-OSX macs any longer, so if it doesn't work it may be 
just tough luck.

--
nosy: +skip.montanaro

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2010-07-10 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
versions: +Python 3.1, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8387] use universal newline mode in csv module examples

2010-04-13 Thread sfinnie

New submission from sfinnie scott.fin...@gmail.com:

Running the examples in the csv module docs 
(http://docs.python.org/library/csv.html) causes problems reading file on a 
mac.  This is highlighted in issue 1072404 
(http://bugs.python.org/issue1072404).

Commentary on the bug indicates a no fix, meaning most/many people using a mac 
will get an error if they use the sample code in the docs.

A simpler solution would be to use universal newline mode in the doc examples.  
This is actually mentioned in commentary on the bug, and appears to work.

Proposal

In all example code blocks, use mode 'rU' when opening the file.  1st code 
block, for example, would become:

spamReader = csv.reader(open('eggs.csv', 'rU'), delimiter=' ', quotechar='|')

That should solve the problem on mac without impacting compatibility on other 
operating systems.  Note: Haven't been able to verify this on other platforms.

--
assignee: georg.brandl
components: Documentation
messages: 103086
nosy: georg.brandl, sfinnie
severity: normal
status: open
title: use universal newline mode in csv module examples
type: feature request
versions: Python 2.6, Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8387
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com