[Python-de] csv mit <type 'str'>
Falk Friedrich
frodo at prima.de
Die Feb 24 18:24:04 CET 2004
Erstmal Danke für die Antworten. :-)
Sind tolle Ideen!
Nur hab ich jetzt das Problem, daß ich das als "Externe Methode"
in zope einbinden will, um dort eine hochgeladene csv-Datei auszuwerten.
zope (hier 2.6.2-6) benutzt nun noch python2.2 (2.2.3-8) und das scheint
anders als python2.3 (2.3.3-5) nicht ganz damit klarzukommen.
Ersmal die Anfänge beider Ansätze, die noch gleichermaßen
gut funktionieren:
---------------------------------
import csv
text = "aaaa;bbbb;cccc\ndddd;eeeee;fffff\n"
data = []
rowlist = text.split("\n")
---------------------------------
import csv
import StringIO
text = "aaaa;bbbb;cccc\ndddd;eeeee;fffff\n"
data = []
rowlist = StringIO.StringIO(text)
---------------------------------
Bis hierhin klappt noch alles.
Die nächste Zeile klappt leider nur mit python 2.3
nicht aber mit python 2.2
csvReader = csv.reader(rowlist, dialect='excel', delimiter = ';')
Python 2.3: alles prima
Python 2.2: Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'reader'
<hoff> Vieleicht hat hier auch jemand ne Idee. :-) </hoff>
TIA, Falk