On Fri, 27 Oct 2006 11:35:40 +0200
Duncan Gibson <[EMAIL PROTECTED]> wrote:

> 
> If I have the following data file, data.csv:
>     1 2 3
>     2 3 4 5
> 
> then I can read it in Python 2.4 on linux using:
> 
>     import csv
>     f = file('data.csv', 'rb')
>     reader = csv.reader(f)
>     for data in reader:
>         print data

Oops, mixing examples here. I forgot to say that
I'm actually using

    reader = csv.reader(f, delimiter=' ')

so it will read the data correctly even if there
isn't a comma in sight in the csv file, but that's
a side issue to the line number problem.

Cheers
Duncan
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to