[Csv] Problems with CSV Module

Andreas.Trawoeger at wgkk.sozvers.at Andreas.Trawoeger at wgkk.sozvers.at
Wed May 21 14:50:43 CEST 2003


Hi!

I am testing Python 2.3b1and have found a couple of problems with the CSV
Module:

1. Documentation:
What's a row? (The word row means a list or a tuple.)
How does DictReader & DictWriter work? Having a couple of examples would
help ;-))

2. Locale:
The CSV module doesn't use locale. The default delimiter for Austria
(+Germany) in Windows is a semicolon ';' not a comma ','.
Having the result, that you can't import a list generated by csv.writer()
in Excel without changing your regional settings, or using
csv.writer(delimiter=';').
It would be nice if the CSV module would adopt to the language settings.

This could be really simple to implement using the locale module. But I
took a short look at the locale module and it seems like there is no way to
get the list separator sign (probably it's not POSIX complaint).

Another possibility would be to have a dialect like 'excel_ger' with the
correct settings.

3. There is no .close()
There is no way to close a file. Resulting in problems with file locking.
Only way around is to do it by hand:

import csv
FILE_CSV    = r"C:\csvtest.csv"

f=file(FILE_CSV,'w')
w=csv.writer(f,dialect='excel',delimiter=';')
w.writerow((1,5,10,25,100,250,500,1000,1500))
f.close()

f=file(FILE_CSV,'r')
r=csv.reader(file(FILE_CSV,'r'),dialect='excel',delimiter=';')
print r.next()
f.close()

4. There is no .readrow()
This should be just another name for .next(). It's more intuitive if you
write a row via .writerow() and read it via .readrow().


Mit freundlichen Grüssen
Andreas Trawöger

Netzwerk  /  Systemadministration
Wiener Gebietskrankenkasse
Tel.:  +43(1) 60122-3664
Fax.: +43(1) 60122-2182




More information about the Csv mailing list