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 andre.lehmann
Recipients andre.lehmann
Date 2019-01-24.10:28:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1548325714.32.0.972508693176.issue35816@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-01-24 10:28:37andre.lehmannsetrecipients: + andre.lehmann
2019-01-24 10:28:34andre.lehmannsetmessageid: <1548325714.32.0.972508693176.issue35816@roundup.psfhosted.org>
2019-01-24 10:28:34andre.lehmannlinkissue35816 messages
2019-01-24 10:28:34andre.lehmanncreate