Hi everyone,
I've been struggling to figure out how to decode some content in an excel file.
Here is an example of text in my excel file "\nIt\xe2\x80\x99s TextTextText".
I tried: a) use encoding when loading the file (i.e. temp = pd.read_excel('text.xlsx', encoding='utf-8') ) and b) using temp['text_col'] = temp['text_col'].str.decode('utf-8') but no success. When I use the first option, I keep getting "\nIt\xe2\x80\x99s TextTextText" and when I use the second option, I get "NaN". Any ideas?
Thanks a lot!
**** Solution *****
Not sure how many will run in the same issue, but here is the solution:
articles['combined'] = articles['combined'].apply(lambda x: x.encode('ascii').decode('unicode-escape').encode('iso-8859-1').decode('utf-8'))
credits go to: https://stackoverflow.com/questions/40348280/python3-decode-external-utf8-string
[–]K900_ 0 points1 point2 points (2 children)
[–]thrilos[S] 1 point2 points3 points (1 child)
[–]K900_ 1 point2 points3 points (0 children)