[issue40463] csv.reader split error

2020-05-01 Thread Eric V. Smith


Eric V. Smith  added the comment:

You should tell us what you're seeing, and what you're expecting.

I'm adding the rest of this not because it solves your problem, but because it 
might help you or someone else troubleshoot this further.

Here's a simpler reproducer:

import csv
lst = ['"A,"h"e, ","E","DC"']

csv_list = csv.reader(lst)
for idx, col in enumerate(next(csv_list)):
print(idx, repr(col))

Which produces:
0 'A,h"e'
1 ' "'
2 'E'
3 'DC'

Although true to its word, this is using the default dialect='excel', and my 
version of Excel gives these same 4 columns, including the space starting the 
second column.

Dropping the space after the "e," gives 3 columns:

lst = ['"A,"h"e,","E","DC"']

Produces:
0 'A,h"e'
1 ',E"'
2 'DC'

Again, this is exactly what Excel gives, as odd as it seems.

It might be worth playing around with the dialect parameters to see if you can 
achieve what you want. In your example:
delimiter=',', quotechar='"'
are the default values for the "excel" dialect, which is why I dropped them 
above.

--
nosy: +eric.smith

___
Python tracker 

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



[issue40463] csv.reader split error

2020-04-30 Thread SilentGhost


Change by SilentGhost :


--
type: enhancement -> behavior
versions: +Python 3.7, Python 3.8 -Python 3.6

___
Python tracker 

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



[issue40463] csv.reader split error

2020-04-30 Thread wy7305e


New submission from wy7305e :

#python 3.6 or python 3.8

csv.reader

delimiter=','
quotechar='"'

split this sentence:

"A word of encouragement and explanation, of pity for my childish ignorance, of 
welcome home, of reassurance to me that it was home, might have made me dutiful 
to him in my heart henceforth, instead of in my hypocritical outside, and might have made me respect 
instead of hate him. ","Part 1/CHAPTER 4. I FALL INTO DISGRACE/","David 
Copperfield"

return 4 columns, but it should return 3 columns.

--
components: Library (Lib)
files: 01_test_code.py
messages: 367823
nosy: wy7305e
priority: normal
severity: normal
status: open
title: csv.reader split error
type: enhancement
versions: Python 3.6
Added file: https://bugs.python.org/file49104/01_test_code.py

___
Python tracker 

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