python csv module error -


when use pythons csv module, shows me

"delimiter" must 1-character string" 

my code this

 sep = ","  srcdata = cstringio.stringio(wdata[1])  data = csv.reader(srcdata, delimiter=sep) 

wdata[1] string source.

how fix problem?

you have from __future__ import unicode_literals @ top of module or using python 3.x+ need this:

sep=b","  # notice b before " srcdata=cstringio.stringio(wdata[1]) data = csv.reader(srcdata,delimiter=sep) 

this tells python want represent "," byte string instead of unicode literal.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -