This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: csv.reader failed to split string with spaces and quoted delimiter
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: belegnar, xtreak
Priority: normal Keywords:

Created on 2019-10-08 17:32 by belegnar, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg354224 - (view) Author: belegnar (belegnar) Date: 2019-10-08 17:32
```
>>> list(csv.reader(['param1,"param21,param22",param3']))
[['param1', 'param21,param22', 'param3']]
>>> list(csv.reader(['param1, "param21,param22", param3']))
[['param1', ' "param21', 'param22"', ' param3']]
```

version 3.7.4 on linux
msg354252 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-10-09 07:32
Can you please add a description of the expected behavior? Does skipinitialspace help with the second input?

https://docs.python.org/3/library/csv.html#csv.Dialect.skipinitialspace

>>> import csv
>>> list(csv.reader(['param1,"param21,param22",param3']))
[['param1', 'param21,param22', 'param3']]
>>> list(csv.reader(['param1, "param21,param22", param3']))
[['param1', ' "param21', 'param22"', ' param3']]
>>> list(csv.reader(['param1, "param21,param22", param3'], skipinitialspace=True))
[['param1', 'param21,param22', 'param3']]
>>> list(csv.reader(['param1,"param21,param22",param3'])) == list(csv.reader(['param1, "param21,param22", param3'], skipinitialspace=True))
True
msg354253 - (view) Author: belegnar (belegnar) Date: 2019-10-09 07:58
Yes, https://docs.python.org/3/library/csv.html#csv.Dialect.skipinitialspace helps
Sorry
msg354254 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-10-09 08:21
No problem, happy it helped :)
History
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82593
2019-10-09 08:21:25xtreaksetresolution: not a bug
2019-10-09 08:21:15xtreaksetmessages: + msg354254
2019-10-09 07:58:06belegnarsetstatus: open -> closed

messages: + msg354253
stage: resolved
2019-10-09 07:32:21xtreaksetnosy: + xtreak
messages: + msg354252
2019-10-08 17:32:00belegnarcreate