New submission from Marco E. <marco.espos...@gmail.com>:
The CSV library does not correctly interpret files in the following format (test.csv): "A" ,"B" ,"C" "aaaaaa","bbbbbbb","cccc" "aaaaa" ,"bbbbbb" ,"ccc" "aaaa" ,"bbbbb" ,"cc" This program: import csv from pathlib import Path def main(): with Path('test.csv').open('rt') as csv_file: csv.register_dialect('my_dialect', quotechar='"', delimiter=',', quoting=csv.QUOTE_ALL, skipinitialspace=True) reader = csv.DictReader(csv_file, dialect='my_dialect') for row in reader: print(row) if __name__ == '__main__': main() produces the following output: {'A ': 'aaaaaa', 'B ': 'bbbbbbb', 'C': 'cccc'} {'A ': 'aaaaa ', 'B ': 'bbbbbb ', 'C': 'ccc'} {'A ': 'aaaa ', 'B ': 'bbbbb ', 'C': 'cc'} this instead is the expected result: {'A': 'aaaaaa', 'B': 'bbbbbbb', 'C': 'cccc'} {'A': 'aaaaa', 'B': 'bbbbbb', 'C': 'ccc'} {'A': 'aaaa', 'B': 'bbbbb', 'C': 'cc'} why? Thank you, Marco ---------- components: Library (Lib) messages: 397139 nosy: voidloop priority: normal severity: normal status: open title: csv library does not correctly interpret some files versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44585> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com