Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫和电子表格_Python_Python 3.x_Pandas - Fatal编程技术网

Python 熊猫和电子表格

Python 熊猫和电子表格,python,python-3.x,pandas,Python,Python 3.x,Pandas,我正在使用ubuntu,因此无法使用ms excel。无论如何,我已经创建了一个电子表格,我希望在我的python程序中使用它。 下面是Python程序 import pandas as pd df=pd.read_excel("/home/files/file1.ods") df.head() Traceback (most recent call last): File "spreadsheet.py", line 2, in <module> df=pd.read_e

我正在使用ubuntu,因此无法使用ms excel。无论如何,我已经创建了一个电子表格,我希望在我的python程序中使用它。 下面是Python程序

import pandas as pd

df=pd.read_excel("/home/files/file1.ods")

df.head()

Traceback (most recent call last):
File "spreadsheet.py", line 2, in <module>
  df=pd.read_excel("/home/files/file1.ods")
File "/usr/lib/python3/dist-packages/pandas/io/excel.py", line 163, in    read_excel
  io = ExcelFile(io, engine=engine)
File "/usr/lib/python3/dist-packages/pandas/io/excel.py", line 187, in __init__
  import xlrd  # throw an ImportError if we need to
ImportError: No module named 'xlrd'

这是否意味着我必须使用ms excel,或者我的理解有误。无论是什么情况,我们都将非常感谢您的帮助

在0.25版以后的最新版本中,提供了此功能

只需使用pip install odfpy或etc安装odfpy包,然后使用带有engine='odf'选项的pandas'read_excel函数即可。例如:

pd.read_excel('path_to_file.ods', engine='odf')

请参阅。

您是否尝试pip安装xlrd?如果您使用的是pycharm之类的工具,请将xlrd添加到您的项目/环境中安装xlrd是不够的。该函数称为read_excel,用于读取excel文件xls和xlsx。如果你想阅读ods,你可以。更好的是,只需使用csv和read_csv函数。您可以使用libreoffice保存到csv、xls或xlsx。读取\u csv工作!!谢谢