" pandas.io.common.EmptyDataError:没有要从文件解析的列"搬到mac后

时间:2017-04-07 05:32:02

标签: python pandas

在Windows 8中,脚本运行正常。在我将脚本和data.csv移动到我的mac中后,我不断收到错误:" pandas.io.common.EmptyDataError:没有要从文件中解析的列。"

脚本和数据与

位于同一文件夹中
"/Users/myname/Downloads/test/testimport.py"
"/Users/myname/Downloads/test/test2.csv"

我已经尝试了很多文件位置来阅读csv,但没有任何作用。

file_loc = "../test/test2.csv"
# as well as "../test2.csv", "/test2.csv", "/Users/myname/Downloads/test/test2.csv"

import pandas as pd
df = pd.read_csv(file_loc)
exp_mat = df.as_matrix()
print exp_mat

我如何在这里阅读csv?这是错误的位置问题还是mac中的csv文件类型不兼容?

这是OS X El Capitan。完整错误是

h143% python testimport.py
Traceback (most recent call last):
  File "test_importexcel.py", line 24, in <module>
    df = pd.read_csv(file_loc)
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pandas/io/parsers.py", line 646, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pandas/io/parsers.py", line 389, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pandas/io/parsers.py", line 730, in __init__
    self._make_engine(self.engine)
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pandas/io/parsers.py", line 923, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pandas/io/parsers.py", line 1390, in __init__
self._reader = _parser.TextReader(src, **kwds)
  File "pandas/parser.pyx", line 538, in pandas.parser.TextReader.__cinit__ (pandas/parser.c:6171)
pandas.io.common.EmptyDataError: No columns to parse from file

数据(从数字复制就像)

x   time    value
445.1207    0.003626    21935450
445.1203    0.011099    36700932
445.1203    0.017235    35722172
445.1203    0.022958    33623668
445.1203    0.028689    33500360
352.3396    37.180567   307886720
352.3396    37.185836   303264100
352.3396    37.191101   292523810

0 个答案:

没有答案