Pandas无法在Windows 10上找到文件

时间:2017-03-13 00:44:46

标签: python windows pandas

# _*_ coding: utf-8

import pandas as pd
import sys

print ''
print 'Pandas Version: ',pd.__version__
print 'Python Version: ',sys.version
print ''

path = 'C:\\Users\\StretchChannel\\Documents\\'
InputFile = path+'test.csv'
df = pd.read_csv(InputFile)

输出是:

Pandas Version:  0.19.2
Python Version:  2.7.13 |Anaconda 4.3.0 (64-bit)| (default, Dec 19 2016, 13:29:36) [MSC v.1500 64 bit (AMD64)]
Traceback (most recent call last): 
  File "test.py", line 12, in <module>
    df = pd.read_csv(InputFile)
  File "C:\ProgramData\Anaconda2\lib\site-packages\pandas\io\parsers.py", line 646, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "C:\ProgramData\Anaconda2\lib\site-packages\pandas\io\parsers.py", line 389, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "C:\ProgramData\Anaconda2\lib\site-packages\pandas\io\parsers.py", line 730, in __init__
    self._make_engine(self.engine)
  File "C:\ProgramData\Anaconda2\lib\site-packages\pandas\io\parsers.py", line 923, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)
  File "C:\ProgramData\Anaconda2\lib\site-packages\pandas\io\parsers.py", line 1390, in __init__
    self._reader = _parser.TextReader(src, **kwds)
  File "pandas\parser.pyx", line 373, in pandas.parser.TextReader.__cinit__ (pandas\parser.c:4184)
  File "pandas\parser.pyx", line 667, in pandas.parser.TextReader._setup_parser_source (pandas\parser.c:8449)
IOError: File C:\Users\StretchChannel\Documents\test.csv does not exist
>Exit code: 1

1 个答案:

答案 0 :(得分:1)

我找到了我的问题的答案:我已将test.xlsx重命名为test.csv ...此文件的Windows 10“官方”名称现在为:test.xlsx.csv

不幸的是,这个双点文件名在查看目录时是隐藏的。实际上,它显示为test.xlsx

我通过点击文件的属性 - &gt;找到了文件的真实姓名。安全。文件名显示在窗口的顶部。

课程:如果Pandas(或Python)找不到该文件,请查看该文件的Windows 10名称属性。

感谢所有看过这个问题的人......