KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a list of dictionaries containing unicode strings. csv.DictWriter can write a list of dictionaries into a CSV file. I want the CSV file to be encoded in UTF8. The csv module cannot handle converting unicode strings into UTF8. The csv module documentation has an example for converting everything to UTF8: def utf_8_encoder(unicode_csv_data): for line in unicode_csv_data: yield line.encode('utf-8') It also has a UnicodeWriter class. But... how do I make DictWriter work with these? Wouldn't they have to inject themselves in the middle of it, to catch the disassembled dictionaries and encode them before it writes them to the file? I don't get it.
Tags (comma-separated)
Save Edits
Cancel