parse a csv file into a text file
Neil Cerutti
neilc at norwich.edu
Thu Feb 6 09:02:31 EST 2014
On 2014-02-06, Zhen Zhang <zhen.zhang.uoft at gmail.com> wrote:
> Hi, every one.
>
> I am a second year EE student.
> I just started learning python for my project.
>
> I intend to parse a csv file with a format like
>
> 3520005,"Toronto (Ont.)",C > ,F,2503281,2481494,F,F,0.9,1040597,979330,630.1763,3972.4,1
[...]
into a text file like the following
>
> Toronto 2503281
[...]
> This is what i have so far.
>
>
> [code]
>
> import csv
> file = open('raw.csv')
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')
--
Neil Cerutti
More information about the Python-list
mailing list