Message334289
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. |
|
Date |
User |
Action |
Args |
2019-01-24 10:28:37 | andre.lehmann | set | recipients:
+ andre.lehmann |
2019-01-24 10:28:34 | andre.lehmann | set | messageid: <1548325714.32.0.972508693176.issue35816@roundup.psfhosted.org> |
2019-01-24 10:28:34 | andre.lehmann | link | issue35816 messages |
2019-01-24 10:28:34 | andre.lehmann | create | |
|