New submission from Eduardo Orochena <[email protected]>:
def load_file(filename):
with open(filename, 'r', encoding='utf-8') as fin:
header = fin.readline()
print('Found ' + header)
reader = csv.DictReader(fin)
for row in reader:
print(type(row), row)
print('Beds {} '.format(row['beds']))
This results in a KeyError exception
whilst
open_f = open(filename, 'r', encoding='utf-8')
read_it = csv.DictReader(open_f)
for i in read_it:
print('Beds {}'.format(i['beds']))
behaves as expected
----------
components: Build
messages: 332810
nosy: eorochena
priority: normal
severity: normal
status: open
title: Python dictreader KeyError issue
type: crash
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35626>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com