[Tutor] converting xls to csv

Sander Sweers sander.sweers at gmail.com
Sat Jun 6 22:39:47 CEST 2009


2009/6/6 Emile van Sebille <emile at fenx.com>:
>> for f in files:
>>    print f
>>    csv.reader(open (f), delimiter=' ', quotechar='|')
>
> you open it here, but don't save a reference to the opened file.  Try...
>      ff = csv.reader(open (f), delimiter=' ', quotechar='|')

<snip>

>    reader(...)
>        csv_reader = reader(iterable [, dialect='excel']
>                                [optional keyword args])
>            for row in csv_reader:
>                process(row)

If you are on windows you should open the file in binary mode.
  open(f, 'rb')

Greets
Sander


More information about the Tutor mailing list