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 steven.daprano
Recipients eorochena, steven.daprano
Date 2018-12-31.11:05:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1546254346.58.0.927206601078.issue35626@roundup.psfhosted.org>
In-reply-to
Content
Can you please provide a *simple* and *complete* demonstration, including the *full* traceback? As given, we cannot run the supplied code and don't know what the contents of the csv file are supposed to be.

See here for more detail: http://www.sscce.org/

But my *guess*, on reading this, is that the line 

    header = fin.readline()

causes the difference. In the first sample, you skip past the first line of the csv file, and so when the dictreader reads the rest of the file, it never sees the first row. But in the second example, it does see the first row.

What happens if you change the first example to this?

        header = fin.readline()
        print('Found ' + header)
        fin.seek(0)
        reader = csv.DictReader(fin)

Does that solve your problem?

Likewise, in the second case, if you change it to this:

    open_f = open(filename, 'r', encoding='utf-8')
    __ = open_f.readline()
    read_it = csv.DictReader(open_f)


what happens?
History
Date User Action Args
2018-12-31 11:05:47steven.dapranosetrecipients: + steven.daprano, eorochena
2018-12-31 11:05:46steven.dapranosetmessageid: <1546254346.58.0.927206601078.issue35626@roundup.psfhosted.org>
2018-12-31 11:05:46steven.dapranolinkissue35626 messages
2018-12-31 11:05:46steven.dapranocreate