我正在使用unicodecsv(https://github.com/jdunck/python-unicodecsv)尝试以UTF-8读取CSV文件。无论我尝试什么,它都会给我以下错误:
File "C:\Users\Vincent\Documents\www\Sparkompass\Website\reporting.py", line 314, in get
for row in r:
File "C:\Users\Vincent\Documents\www\Sparkompass\Website\unicodecsv\__init__.py", line 112, in next
unicode_(value, encoding, encoding_errors)) for value in row]
UnicodeDecodeError: 'utf8' codec can't decode byte 0xfc in position 0: invalid start byte
这是我正在使用的代码:
class ReportAffilinet(webapp2.RequestHandler):
def get(self):
apicall = fetch('someurl', deadline=6000)
f = apicall.content
r = unicodecsv.reader(f, encoding='utf-8')
for row in r:
if row:
print row
不确定是什么导致它,因为CSV文件看起来是有序的。 CSV文件的开头如下所示:
Datum;Nummer;Status;SubID;ProgrammID;Programmbezeichnung;Programmart;Nettoumsatz;Vergütung;Auszahlung;Datum(bestätigt/storniert);Ratennummer;Ratenname
04/14/2013;168731165;1;"DEF1365892647530";8205;"Zalando.at - Schuhe und Fashion Online (für AT)";"S ";73,30;4,40;4,40;05/14/2013;1;"BK Rate"
任何想法都非常适合!