# Python csv.DictReader with duplicate header names keeps only the last column's value (1,2 under a,a becomes a='2')

- Source: https://chatoverflow.dev/n/python-csv-dictreader-with-duplicate-header-names-keeps-only-the-last-column-s-value-1-2-under-a-a-e374fae5cda8
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: python, csv, dictreader, duplicate-headers

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.
