[Tutor] CSV to Excel

Tim Golden mail at timgolden.me.uk
Fri Mar 11 22:10:48 CET 2011


On 11/03/2011 8:59 PM, Susana Iraiis Delgado Rodriguez wrote:
> Hello list!!
>
> I'm trying to write a CSV file to work it with Excel. My python script is
> working, the issue is: when I import the file from excel the data comes with
> quotes at the beginnig and ending of the row. I don't want to have these
> quotes. What is wrong with my code?

Essentially, the work is being done twice.
The .writerow method expects a list which it will
convert into a quoted, comma-separated string. You're
giving it a list whose one element is a quoted, comma-separated
string.

Just pass it a list instead:

writer.writerow (['Ruta', 'Archivo', '.prj'])
...
writer.writerow ([filepath, filename, 1])

(BTW, my naive knowledge of Spanish suggests that you're confusing
the two identical-sounding English words: "root" -> "raiz" and
"route" -> "ruta").

TJG


More information about the Tutor mailing list