I have a socket server that is supposed to receive UTF-8 valid characters from clients.
The problem is some clients (mainly hackers) are sending all the wrong kind of
I have resolved this problem using this code
df = pd.read_csv(gdp_path, engine='python')
Just in case of someone has the same problem. I'am using vim with YouCompleteMe, failed to start ycmd with this error message, what I did is: export LC_CTYPE="en_US.UTF-8"
, the problem is gone.
the first,Using get_encoding_type to get the files type of encode:
import os
from chardet import detect
# get file encoding type
def get_encoding_type(file):
with open(file, 'rb') as f:
rawdata = f.read()
return detect(rawdata)['encoding']
the second, opening the files with the type:
open(current_file, 'r', encoding = get_encoding_type, errors='ignore')
I have solved this problem just by adding
df = pd.read_csv(fileName,encoding='latin1')