Linked Questions
19 questions linked to/from Write to UTF-8 file in Python
3 votes
2 answers
14k views
UTF8 Python BOM [duplicate]
Possible Duplicate: Write to utf-8 file in python I have Unicode strings (with Japanese characters) I want to write to a CSV file. However, the BOM does not seem to be written correctly, just as a ...
0 votes
4 answers
248 views
Python 3.4 unicode character displayed correctly on console but no in text file [duplicate]
My current code, displays the results in both console and an output text file with the following statement fw.write("Number of files processed within 512\u00B1 1 samples: "+str(count)) My ...
1186 votes
22 answers
1.0m views
What's the difference between UTF-8 and UTF-8 with BOM?
What's different between UTF-8 and UTF-8 with BOM?
1149 votes
16 answers
2.0m views
UnicodeDecodeError: 'charmap' codec can't decode byte X in position Y: character maps to <undefined>
I'm trying to get a Python 3 program to do some manipulations with a text file filled with information. However, when trying to read the file I get the following error: Traceback (most recent call ...
4 votes
3 answers
9k views
Python Writing Weird Unicode to CSV
I'm attempting to extract article information using the python newspaper3k package and then write to a CSV file. While the info is downloaded correctly, I'm having issues with the output to CSV. I don'...
6 votes
2 answers
10k views
python write unicode to file easily?
I want to make sure all string are unicode in my code, so I use unicode_literals, then I need to write string to file: from __future__ import unicode_literals with open('/tmp/test', 'wb') as f: f....
1 vote
4 answers
3k views
Removing special characters (¡) from a string
I am trying to write into a file from a collection. The collection has special characters like ¡ which create a problem. For example the content in the collection has details like: {..., Name: ¡Hi!,...
0 votes
1 answer
6k views
How to mannually specify Byte Order Mark in CSV
I have a CSV that is encoded in Unicode, however lacks a byte order mark at the start. As such Excel (2013) opens without encoding correctly (i think it assumes ASCII if no BOM specified...), meaning ...
1 vote
1 answer
2k views
self.writer.writerow([s.encode('utf-8') for s in row])
I am trying to write into a file (in Python), but it says: 'ManyRelatedManager' object has no attribute 'encode' Here is the code: self.writer.writerow([s.encode('utf-8') for s in row]) Is there a ...
1 vote
1 answer
1k views
Python ignores encoding argument in favor of cp1252
I have a lengthy json file that contains utf-8 characters (and is encoded in utf-8). I want to read it in python using the built-in json module. My code looks like this: dat = json.load(open("data....
0 votes
2 answers
915 views
CSV Module - write German to CSV in python
I'm reading german names from a csv, and want to write them in a csv file, with the right encoding for ä, ö and ü. Reading works fine, but when I write to the csv, the characters are displayed like ...
0 votes
1 answer
772 views
How do I get rid of non-printable characters?
Just for fun, I am trying to create a batch renaming application in Python 3.6.0 which is supposed to capture, split the file name based on regex, and properly name the files. For testing purposes, I ...
0 votes
0 answers
409 views
Output chinese in csv and opened with excel is gibberish in python
Hi everyone~ I'm new to python ~ Does anyone know that I can crawl the data(the string mix with Chinese and English) into python_job.csv and I can open with excel but the Chinese part all become ...
1 vote
2 answers
328 views
Python saving unicode to XML
I'm currently writing a short Python script to walk through some directories on a server, find what I'm looking for and save the data to an XML file. The problem is that some of the data is written ...
1 vote
2 answers
146 views
Unexpected behaviour of t.unicode('utf-8') - Python
I have a json file with several keys. I want to use one of the keys and write that string to a file. The string originally is in unicode. So, I do, s.unicode('utf-8') Now, there is another key in ...