Solution to garbled characters when opening CSV files

Ideas

Just use third-party software to transcode.

Case

Opening the CSV file displays the following:
Insert image description here

  • Import into python and read with pandas file
    Insert image description here
  • Just save it as csv file format.
    The code is as follows:
import pandas as pd
df = pd.read_csv(r'D:\BaiduNetdiskDownload\csv&xlsx版数据\城市产业创新指数2001-2021\城市产业创新指数2001-2021.csv')
df.to_csv(r'D:\BaiduNetdiskDownload\csv&xlsx版数据\城市产业创新指数2001-2021\【格式转码】城市产业创新指数2001-2021.csv')

another way

Use notepad to open the garbled csv file
右键打开方式----记事本
Insert image description here
文件----另存为
Insert image description here编码调整为:ANSI
. After saving, open it with excel.
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_43213884/article/details/132888837