How to save non-English words in CSV with Python?

Viewed 462

I am working on scraping script with Selenium library in Python (LinkedIn website). After scraping I want to save data in a CSV file. But after saving data in CSV, the language of data is changing.

For example, I want to scrape (ABC XYZ 叶官杰)

The output in Python shows exactly same with print(profileName), but after saving in CSV it changes to (ABC XYZ å¶å®˜æ°).

The python code for saving the data is:

OP_csv = r'C:\foldername\filename.csv'
def SaveDataInCSV(mRow):
    with open(OP_csv, 'a', newline='', encoding="utf-8") as appendFile:
        writer = csv.writer(appendFile)
        writer.writerow(mRow)
        
    appendFile.close() 

I tried both utf-8 and utf-8-sg encoding type. But none of them is working.

Please help to save data exactly shown on the website.

EDIT: I noticed that, if I open same CSV file in notepad++ then all text showed exactly same. It is the problem of Excel that is unable to recognize.

I've found the solution in this link http://www.openforis.org/support/questions/279/wrong-characters-display-when-exporting-files-to-csv-from-collect

0 Answers
Related