This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eorochena
Recipients eorochena
Date 2018-12-31.10:53:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1546253603.09.0.372827657102.issue35626@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2018-12-31 10:53:26eorochenasetrecipients: + eorochena
2018-12-31 10:53:23eorochenasetmessageid: <1546253603.09.0.372827657102.issue35626@roundup.psfhosted.org>
2018-12-31 10:53:23eorochenalinkissue35626 messages
2018-12-31 10:53:23eorochenacreate