[issue25857] csv: unexpected result

2015-12-14 Thread R. David Murray

R. David Murray added the comment:

Yeah, we'll leave it alone until someone actually submits an enhancment 
request...and the only way it'll get done is if they do it, I suspect :)

--

___
Python tracker 

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



[issue25857] csv: unexpected result

2015-12-14 Thread Ioan Fintescu

Ioan Fintescu added the comment:

If you consider that, you should take a look at the RFC; it also contains a
BNF like grammar plus some pointers to another RFC (2234).  It may require
more effort that it is worth, absent some demand for it.

...muss

On Mon, Dec 14, 2015 at 9:34 AM, R. David Murray 
wrote:

>
> R. David Murray added the comment:
>
> Oh, maybe there is.  We could add an RFC-strict dialect that would raise
> an error, if I'm understanding your quotes from it correctly.  That would
> be a new feature, though.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue25857] csv: unexpected result

2015-12-14 Thread R. David Murray

R. David Murray added the comment:

There's no place to generate an error message, the csv module parsed the line 
according to the rules.

I'm glad that there's an RFC now.  There wasn't when the module was written 
(which was well before my time on this project...)

--

___
Python tracker 

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



[issue25857] csv: unexpected result

2015-12-14 Thread R. David Murray

R. David Murray added the comment:

Oh, maybe there is.  We could add an RFC-strict dialect that would raise an 
error, if I'm understanding your quotes from it correctly.  That would be a new 
feature, though.

--

___
Python tracker 

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



[issue25857] csv: unexpected result

2015-12-14 Thread Ioan Fintescu

Ioan Fintescu added the comment:

There seems to be a CSV specification, namely IETF RFC 4180, and, as far as
I can tell, it indicates you are correct, and I am wrong.  Especially
points 5., 6., and 7 on page 3.  Here is a quote from 5 (RFC 4180, page 2
).

If fields are not enclosed with double quotes, then double quotes may not
> appear inside the fields.

It gets more specific in 6., and 7.

So the csv module is doing the right thing.  An error message may help,
though.

...muss

On Mon, Dec 14, 2015 at 9:05 AM, R. David Murray 
wrote:

>
> R. David Murray added the comment:
>
> Well, since there's no real standard for csv, it might have been.  Since
> it is iherently ambiguous according to "normal" csv rules, though, I'd say
> that if that is the case the originating spreadsheet is the one with the
> bug.  If you can prove there is a spreadsheet that uses this format,
> perhaps an enhancement request for csv would be in order.  I don't *think*
> there's any way to parse that with the existing dialect support, though I
> could be wrong.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue25857] csv: unexpected result

2015-12-14 Thread R. David Murray

R. David Murray added the comment:

Well, since there's no real standard for csv, it might have been.  Since it is 
iherently ambiguous according to "normal" csv rules, though, I'd say that if 
that is the case the originating spreadsheet is the one with the bug.  If you 
can prove there is a spreadsheet that uses this format, perhaps an enhancement 
request for csv would be in order.  I don't *think* there's any way to parse 
that with the existing dialect support, though I could be wrong.

--

___
Python tracker 

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



[issue25857] csv: unexpected result

2015-12-13 Thread Ioan Fintescu

Ioan Fintescu added the comment:

You may be right.  I just saved it from LibreOffice Calc and I got
[x=ā€aā€,"y=ā€b, cā€"].  I thought the original was saved from a spreadsheet
program.

...muss

On Sun, Dec 13, 2015 at 7:51 PM, Ioan Fintescu  wrote:

> You wrote ['x = "a"', 'y = "b, c"']
> I wrote ['x = "a", y = "b, c"']
>
>
> ...muss
>
>
> On Sun, Dec 13, 2015 at 7:08 PM, R. David Murray 
> wrote:
>
>>
>> R. David Murray added the comment:
>>
>> >>> b = io.StringIO()
>> >>> w = csv.writer(b)
>> >>> w.writerow(['x = "a"', 'y = "b, c"'])
>> 28
>> >>> b.getvalue()
>> '"x = ""a""","y = ""b, c"""\r\n'
>>
>>
>> In other words, your input was not validly quoted csv.
>>
>> --
>> nosy: +r.david.murray
>> resolution:  -> not a bug
>> stage:  -> resolved
>> status: open -> closed
>>
>> ___
>> Python tracker 
>> 
>> ___
>>
>
>

--

___
Python tracker 

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



[issue25857] csv: unexpected result

2015-12-13 Thread Ioan Fintescu

Ioan Fintescu added the comment:

You wrote ['x = "a"', 'y = "b, c"']
I wrote ['x = "a", y = "b, c"']

...muss

On Sun, Dec 13, 2015 at 7:08 PM, R. David Murray 
wrote:

>
> R. David Murray added the comment:
>
> >>> b = io.StringIO()
> >>> w = csv.writer(b)
> >>> w.writerow(['x = "a"', 'y = "b, c"'])
> 28
> >>> b.getvalue()
> '"x = ""a""","y = ""b, c"""\r\n'
>
>
> In other words, your input was not validly quoted csv.
>
> --
> nosy: +r.david.murray
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue25857] csv: unexpected result

2015-12-13 Thread R. David Murray

R. David Murray added the comment:

>>> b = io.StringIO()
>>> w = csv.writer(b)
>>> w.writerow(['x = "a"', 'y = "b, c"']) 
28
>>> b.getvalue()
'"x = ""a""","y = ""b, c"""\r\n'


In other words, your input was not validly quoted csv.

--
nosy: +r.david.murray
resolution:  -> not a bug
stage:  -> 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



[issue25857] csv: unexpected result

2015-12-13 Thread Ioan Fintescu

New submission from Ioan Fintescu:

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> s = 'x = "a", y = "b, c"'
>>> s
'x = "a", y = "b, c"'
>>> for row in csv.reader([s]): print(row)
...
['x = "a"', ' y = "b', ' c"']
>>> len(row)
3
>>> for row1 in csv.reader([s], skipinitialspace=True):print(row1)
...
['x = "a"', 'y = "b', 'c"']
>>> len(row1)
3
>>> s2 = 'x = "a",y="b,c"'
>>> s2
'x = "a",y="b,c"'
>>> for row2 in csv.reader([s]): print(row2)
...
['x = "a"', ' y = "b', ' c"']
>>> len(row2)
3
>>> for row3 in csv.reader([s], skipinitialspace=True): print(row3)
...
['x = "a"', 'y = "b', 'c"']
>>> len(row3)
3

--
messages: 256355
nosy: muss
priority: normal
severity: normal
status: open
title: csv: unexpected result
type: behavior
versions: Python 3.4

___
Python tracker 

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