ich versuche vergebens einen Teil einer CSV Datei nach MySQL zu importieren.
Die ersten 10000 Zeilen importieren sauber, doch beim zweiten Teil mache ich irgendwo einen
Fehler.
Code: Alles auswählen
with open('exportall.csv', 'rb') as csvfile2:
reader2 = csv.reader(csvfile2, delimiter=';', quotechar='"')
i=0
for row1 in reader2:
i=i+1
if i>=start1 and i<=end:
print(i)
elif i>=start2:
print(row1)
try:
cursor.execute("INSERT INTO tradeposition (trade,posnumber,ptype,numer,title,unit,buperou,quantity,price,discount,surcharge,vattype,costtype,shippingweight) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);", row1)
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
sys.exit(1)
db.commit()
db.close()
Die Zeile die nicht importiert samt Error lautet:
['IN1015', '0.01', '0', '0914', 'Abh\xc3\xa4ngehaken, einfach', 'L\xc3\xa4nge 15cm, f\xc3\xbcr Locatelli-W\xc3\xa4nde Quadratlochung 11x11mm, RAL 9006', ' ', '1', '300', '3.0000', '0', '0.00', '0', '', '']
Traceback (most recent call last):
File "DPS-NEW.py", line 268, in <module>
importTradePosition()
File "DPS-NEW.py", line 228, in importTradePosition
cursor.execute("INSERT INTO tradeposition (trade,posnumber,ptype,numer,title,unit,buperou,quantity,price,discount,surcharge,vattype,costtype,shippingweight) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);", row1)
File "build/bdist.macosx-10.5-x86_64/egg/MySQLdb/cursors.py", line 187, in execute
TypeError: not all arguments converted during string formatting
Hoffe jemand hat eine Idee.
Danke im Voraus