Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

CSVKitDictWriter.writerow() throws typeerror #182

Closed
janschulz opened this Issue Aug 16, 2012 · 0 comments

Comments

Projects
None yet
2 participants
Contributor

janschulz commented Aug 16, 2012

The problem is in line 77:

# Convert embedded Mac line endings to unix style line endings so they get quoted
row = dict([(k, v.replace('\r', '\n')) if isinstance(v, basestring) else v for k, v in row.items()])

If v is not a string, the resulting list is not a list of tuples but just of 'v's.

The fix was:

# Convert embedded Mac line endings to unix style line endings so they get quoted
row = dict([(k, v.replace('\r', '\n')) if isinstance(v, basestring) else (k,v) for k, v in row.items()])

-> also return a tuple if v is not a string

@onyxfish onyxfish closed this in b68fecf Aug 17, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment