I have a CSV file which has two columns 'title' and 'description' . The Description columns has HTML elements . I am trying to replace 'InterviewNotification' with InterviewAlert .
This is the code i wrote :
text = open("data.csv", "r")
text = ''.join([i for i in text]).replace("InterviewNotification", "InterviewAlert")
x = open("output.csv","w")
x.writelines(text)
x.close()
But, Im getting this Error :
File "C:\Users\Zed\AppData\Local\Programs\Python\Python39\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 5786: character maps to <undefined>
Also used pandas , here is the code :
dataframe = pd.read_csv("data.csv")
# using the replace() method
dataframe.replace(to_replace ="InterviewNotification", value = "InterviewAlert", inplace = True)
still no Luck. Help pls
UTFby default. your data is probably not using it, so you should check the original document encoding, then read the file withopen(path, 'rb')and decode the resulting bytes string with the correct format>when editing.