49125/python-unicodeencodeerror-encode-character-position-ordinal
I'm trying to write a to a csv file, I get the following error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\u03b1' in position 20: ordinal not in range(128)
Line causing error:
df.to_csv('out.csv')
use the sep argument of to_csv, to delimit by a tab:
df.to_csv(file_name, sep='\t')
To use a specific encoding (e.g. 'utf-8') use the encoding argument:
df.to_csv(file_name, sep='\t', encoding='utf-8')
import csv import sys reload(sys) sys.setdefaultencoding('utf8') data = [["a", "b", u'\xe9']] with open("output.csv", "w") as csv_file: writer = csv.writer(csv_file, quoting=csv.QUOTE_ALL) writer.writerows(data)
Hi. I am getting the following error when I ran this script:
NameError: name 'reload' is not defined
Use the following line to import the module
from importlib import reload
In Python 2, this was in build but in python, you've to use importlib.
You are getting this error because you ...READ MORE
This error occurs because you are using ...READ MORE
import speech_recognition as sr r = sr.Recognizer() audio ='C\Users\Desktop\audiofile1.wav' with ...READ MORE
TRY THIS #Nomalisation for i in names: print(i) ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
can you give an example using a ...READ MORE
You can simply the built-in function in ...READ MORE
add the following line on top of ...READ MORE
You have to use the encoding as latin1 ...READ MORE
OR
Already have an account? Sign in.