Python pandas.errors.EmptyDataError:读取csv文件时,没有要从文件中解析的列

Python pandas.errors.EmptyDataError:读取csv文件时,没有要从文件中解析的列,python,Python,我正在运行一个程序来读取csv文件并将数据保存在列表中,以便以后以不同的布局重新写入csv文件。代码如下: def read_csv(filename): date = ["Date"] high = ["High"] low = ["Low"] close = ["Close"] volume = ["Volume"] adj_close = [&

我正在运行一个程序来读取csv文件并将数据保存在列表中,以便以后以不同的布局重新写入csv文件。代码如下:

def read_csv(filename):
    date = ["Date"]
    high = ["High"]
    low = ["Low"]
    close = ["Close"]
    volume = ["Volume"]
    adj_close = ["Adj Close"]

    df = pd.read_csv(filename, usecols=date)
    print(df)
    Date.append(df)

    df = pd.read_csv(filename, usecols=high)
    print(df)
    High.append(df)

    df = pd.read_csv(filename, usecols=low)
    print(df)
    Low.append(df)

    df = pd.read_csv(filename, usecols=close)
    print(df)
    Close.append(df)

    df = pd.read_csv(filename, usecols=volume)
    print(df)
    Volume.append(df)

    df = pd.read_csv(filename, usecols=adj_close)
    print(df)
    Adj_Close.append(df)
但是,每次我运行它时,都会出现以下错误:

Traceback (most recent call last):
  File "C:\Users\sande\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "c:/Users/sande/Desktop/Vihaan/ThirdPartySoftware/Python/VisualStudiosCode/DadWork/Converter.py", line 116, in to_av
    createData(filename)
  File "c:/Users/sande/Desktop/Vihaan/ThirdPartySoftware/Python/VisualStudiosCode/DadWork/Converter.py", line 93, in createData
    copyCol(i, 1, len(Date), filename)
  File "c:/Users/sande/Desktop/Vihaan/ThirdPartySoftware/Python/VisualStudiosCode/DadWork/Converter.py", line 72, in copyCol
    read_csv(filename)
  File "c:/Users/sande/Desktop/Vihaan/ThirdPartySoftware/Python/VisualStudiosCode/DadWork/Converter.py", line 31, in read_csv
    df = pd.read_csv(filename, usecols=date)
  File "C:\Users\sande\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py", line 686, in read_csv
    return _read(filepath_or_buffer, kwds)
  File "C:\Users\sande\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py", line 452, in _read
    parser = TextFileReader(fp_or_buf, **kwds)
  File "C:\Users\sande\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py", line 946, in __init__
    self._make_engine(self.engine)
  File "C:\Users\sande\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py", line 1178, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)
  File "C:\Users\sande\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\io\parsers.py", line 2008, in __init__
    self._reader = parsers.TextReader(src, **kwds)
  File "pandas\_libs\parsers.pyx", line 540, in pandas._libs.parsers.TextReader.__cinit__
pandas.errors.EmptyDataError: No columns to parse from file
我的运行代码如下:

def copyCol(filename):
    read_csv(filename)

有人能告诉我为什么会发生这种情况吗?

请检查您的文件是否没有头或是空的,它是否同时有两个头。。。是否可以在csv文件中共享头文件?