-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: "delimiter" must be string, not unicode #36
Comments
Same problem for me: delimiter and quotechar keywordargs for delimiter=str(u';'), quotechar=str(u'"') Here the u prefix is just for clarity, most of the time my 2.7 module have |
Can't this be handled by the library? The encoding of the CSV is provided. |
Yes, it can. I'll try to work this up soon. |
In addition to making sure it's a string, it also need to make sure it's a one-byte string when it's done. The reader only support single character |
Hate to pull the old '+1', but just ran in to this trying to make my lib work with both py2 and py3. Many things seem to be a lot easier than with the builtin As I was already using from __future__ import unicode_literals
import csv
import six
if six.PY2:
import unicodecsv as csv
def export(fname, …, delimiter='\t', …):
if six.PY2:
output = open(fname, 'wb')
delimiter = delimiter.encode('utf-8')
else:
output = open(fname, 'w')
…
with output:
writer = csv.DictWriter(output, …, delimiter=delimiter, …)
… Getting rid of the first bit would be awesome. |
Python 2.7:
The text was updated successfully, but these errors were encountered: