New submission from André Lehmann <andre.lehm...@siemens.com>:

When using the csv.DictReader a dialect can be given to change the behavior of 
interpretation of the csv file.

The Dialect has an option "skipinitialspace" which shall ignore the whitespace 
after the delimiter according to the documentation 
(https://docs.python.org/3/library/csv.html).

Unfortunately this works only for spaces but not for tabs which are also 
whitespaces.

See the following code snippet applied on the attached file:

with open("conf-csv", "r") as csvfile:
    csv.register_dialect("comma_and_ws", skipinitialspace=True)
    csv_dict_reader = csv.DictReader(csvfile, dialect="comma_and_ws")
    for line in csv_dict_reader:
        print(line)

The second line shall not contain "\t" chars.

----------
files: conf.csv
messages: 334289
nosy: andre.lehmann
priority: normal
severity: normal
status: open
title: csv.DictReader, skipinitialspace does not ignore tabs
type: behavior
versions: Python 3.5
Added file: https://bugs.python.org/file48075/conf.csv

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35816>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to