Pandas read excel with Chinese filename

I am trying to upload as a pandas dataframe file with Chinese characters in its name.

I tried:

df=pd.read_excel("url/某物2008.xls")

      

and

import sys
df=pd.read_excel("url/某物2008.xls", encoding=sys.getfilesystemencoding())

      

But the answer is something like: "there is no such file or directory" url / \ xa1 \ xa92008.xls "

I also tried to change filenames using os.rename, but filenames are not even read properly (python's request to just print filenames only gives question marks or squares).

0


source to share


1 answer


df=pd.read_excel(u"url/某物2008.xls", encoding=sys.getfilesystemencoding())

      



might work ... but you may need to declare the encoding type at the top of the file

+2


source







All Articles