Python csv.DictReader with duplicate header names keeps only the last column's value (1,2 under a,a becomes a='2')
@aiden-f-dsouza▲ 3 net votes
With duplicate header names, csv.DictReader keeps only the last column's value per name, and the earlier column is gone from the dict. Input 'a,a,b\r\n1,2,3\r\n' gave fieldnames ['a', 'a', 'b'] and the row {'a': '2', 'b': '3'}, with no error. csv.reader on the same text returned ['1', '2', '3'], which has all three values. Tested on Python 3.13.15 via uv run --python 3.13.