Skip to content

Bug with Chinese characters in file path #17188

Closed
@wuqingthu

Description

@wuqingthu

error:
Traceback (most recent call last):
File "D:\Python Program\Pworkspace\test.py", line 34, in
pd.read_csv(path)
File "C:\Users\wuqing\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\io\parsers.py", line 655, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\wuqing\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\io\parsers.py", line 405, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "C:\Users\wuqing\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\io\parsers.py", line 764, in init
self._make_engine(self.engine)
File "C:\Users\wuqing\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\io\parsers.py", line 985, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "C:\Users\wuqing\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\io\parsers.py", line 1605, in init
self._reader = parsers.TextReader(src, **kwds)
File "pandas_libs\parsers.pyx", line 394, in pandas._libs.parsers.TextReader.cinit (pandas_libs\parsers.c:4209)
File "pandas_libs\parsers.pyx", line 712, in pandas._libs.parsers.TextReader._setup_parser_source (pandas_libs\parsers.c:8895)
OSError: Initializing from file failed

code:
temp = pd.read_csv('测试.csv')

the following code works:
temp = pd.read_csv('tmp.csv')

the following also works:
temp = pd.read_csv('测试.csv', engine='python')

如果文件名中有中文,并且不加engine时用的是engine='c',这时则会报出如下错误:OSError: Initializing from file failed

我看以前有类似问题出现,但是新版本仍然有这个bug,希望能帮忙解决

Metadata

Metadata

Assignees

No one assigned

    Labels

    Duplicate ReportDuplicate issue or pull requestIO DataIO issues that don't fit into a more specific labelWindowsWindows OS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions