Best way to parse file into db-type layout?
John Machin
sjmachin at lexicon.net
Fri Apr 29 18:59:11 EDT 2005
On Fri, 29 Apr 2005 23:21:43 +0100, Michael Hoffman
<cam.ac.uk at mh391.invalid> wrote:
>John Machin wrote:
>> [Michael Hoffman]:
>>
>>>for row in csv.reader(fileinput.input()):
>>
>> csv.reader requires that if the first arg is a file that it be opened
>> in binary mode.
>
>fileinput.input() is not a file.
Hair-splitter. fileinput opens its files in text mode.
It's an awk simulation and shouldn't be used for real-world data.
>
>I have tested this code and it works fine for the provided example.
Well I've got news for you: real-world data has embedded CRs, LFs and
(worst of all) ^Zs often enough, and you won't find them mentioned in
any documentation, nor find them in examples.
More information about the Python-list
mailing list