parse a csv file into a text file

Tim Golden mail at timgolden.me.uk
Thu Feb 6 13:05:08 EST 2014


On 06/02/2014 17:40, Mark Lawrence wrote:
> On 06/02/2014 14:02, Neil Cerutti wrote:
>>
>> You must open the file in binary mode, as that is what the csv
>> module expects in Python 2.7. newline handling can be enscrewed
>> if you forget.
>>
>> file = open('raw.csv', 'b')
>>
>
> I've never opened a file in binary mode to read with the csv module
> using any Python version.  Where does it state that you must do this?
>

If you don't, you tend to get interleaved blank lines. (Presumably 
unless your .csv is using \n-only linefeeds).

TJG



More information about the Python-list mailing list