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.

Author tegdev
Recipients berker.peksag, krypten, r.david.murray, rhettinger, samwyse, serhiy.storchaka, skip.montanaro, tegdev
Date 2019-05-05.17:19:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557076778.73.0.83887257756.issue23041@roundup.psfhosted.org>
In-reply-to
Content
The correct handling of None values belongs to the csv module.

There is a use case to migrate a DB2 database to PostgreSQL.
DB2 has a command line tool "db2 export ..." which produces csv-files.
A row 
  ['Hello', null, 'world'] 
is exported to
  "Hello,,"world".

I would like to read in these exports with python and put it to PostgreSQL.

But with the csv library I can't read it in correctly. The input is converted to:
  ['Hello', '', 'world']
It should read as:
  ['Hello', None, 'world']

It is pretty easy to write a correct CSV reader with ANTLR but it's terribly slow.

And last but not least: if someone writes a list the reading should the identity.
Thats not True for the csv libraray.

Example:

import csv
hello_out_lst = ['Hello', None, 'world']
with open('hello.csv', 'w') as ofh:
    writer = csv.writer(ofh, delimiter=',')
    writer.writerow(hello_out_lst)

with open('hello.csv', 'r') as ifh:
    reader = csv.reader(ifh, delimiter=',')
    for row in reader:
        hello_in_lst = row

is_equal = hello_out_lst == hello_in_lst
print(f'{hello_out_lst} is equal {hello_in_lst} ?  {is_equal}')

The result is:
['Hello', None, 'world'] is equal ['Hello', '', 'world'] ?  False
History
Date User Action Args
2019-05-05 17:19:38tegdevsetrecipients: + tegdev, skip.montanaro, rhettinger, samwyse, r.david.murray, berker.peksag, serhiy.storchaka, krypten
2019-05-05 17:19:38tegdevsetmessageid: <1557076778.73.0.83887257756.issue23041@roundup.psfhosted.org>
2019-05-05 17:19:38tegdevlinkissue23041 messages
2019-05-05 17:19:38tegdevcreate