读取ODS文件并将其作为pandas.dataframe返回
pandas-ods-reader的Python项目详细描述
熊猫阅读器
提供读取ODS文件并返回Pandas数据帧的函数。
它使用ezodf
读取ods文件。如果工作表中指定了范围
要导入,似乎ezodf
还导入空单元格。因此,
完全空的行和列在
返回。只删除后面的空行和空列。
如果ods文件包含重复的列名,它们将被编号,并且 数字将附加到结果数据帧中的列名。
依赖关系
ezodf
lxml
pandas
安装
pip install pandas_ods_reader
用法
frompandas_ods_readerimportread_odspath="path/to/file.ods"# load a sheet based on its index (1 based)sheet_idx=1df=read_ods(path,sheet_idx)# load a sheet based on its namesheet_name="sheet1"df=read_ods(path,sheet_name)# load a file that does not contain a header row# if no columns are provided, they will be numbereddf=read_ods(path,1,headers=False)# load a file and provide custom column names# if headers is True (the default), the header row will be overwrittendf=read_ods(path,1,columns=["A","B","C"])