问题
I am really beginning at python, but I am hours in this line, can't go anywhere without fixing it.
cadastro_2019_10= pd.read_csv("inf_cadastral_fi_20191015.csv",delimiter=";")[["CNPJ_FUNDO","DENOM_SOCIAL","CLASSE"]]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc9 in position 49: invalid continuation byte
cadastro_2019_10= pd.read_csv("inf_cadastral_fi_20191015.csv",delimiter=";")[["CNPJ_FUNDO","DENOM_SOCIAL","CLASSE"]]
again:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc9 in position 388: invalid continuation byte
回答1:
Figure out what encoding the CSV file uses. Seems it doesn't use UTF-8. Say it's latin1, then you can try with read_csv(..., encoding="latin1")
.
If you are on a UNIX system, you can use the file
command to try to detect the encoding.
回答2:
I found that I had to add :encoding='cp1252' but thank you for your time
来源:https://stackoverflow.com/questions/58421078/unicodedecodeerror-utf-8-codec-cant-decode-byte-0xc9-in-position-388-invali