简体   繁体   English

在python中读取.xls文件(使用pandas read_excel)

[英]Reading an .xls file in python (using pandas read_excel)

So I have an .xls file which I am able to open with Excel and also with Notepad (can see the numbers along with some other text) but I cannot read the file using pandas module. 因此,我有一个.xls文件,可以使用Excel和记事本打开(可以看到数字以及其他一些文本),但无法使用pandas模块读取该文件。

df = pd.read_excel(r'"R:\Project\Projects\429 - Buchner Höhe\Analysis Data\scada\20171101.xls"',parse_dates=[[0,1,2,3]]) 

The error which pops up is as follows: 弹出的错误如下:

XLRDError: Unsupported format, or corrupt file: Expected BOF record; XLRDError:不支持的格式,或文件损坏:预期的BOF记录; found b'\\x03\\x11\\x0b\\x02 \\x01\\x00\\x00' 找到b'\\ x03 \\ x11 \\ x0b \\ x02 \\ x01 \\ x00 \\ x00'

I tried renaming the file to .xlsx using os.rename , it still does not work. 我尝试使用os.rename将文件重命名为.xlsx ,但仍然无法正常工作。

It is quite likely the file was already a csv file--not an xls or xlsx, renamed through the file system, rather than an actual Excel format file. 该文件很可能已经是一个csv文件,而不是通过文件系统重命名的xls或xlsx,而不是实际的Excel格式文件。 This is the error generated when you attempt to open a csv with xlrd. 这是您尝试使用xlrd打开CSV时生成的错误。

The indicator that this is the case is you can open it with Notepad. 可以通过记事本将其打开的指示符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 pandas read_excel 不能正确读取 xls 文件? - Why pandas read_excel not reading correctly xls file? 使用 pandas read_excel() 将.xls 文件格式导入 python 时出现 CompDocError - CompDocError when importing .xls file format to python using pandas read_excel() Python:Pandas read_excel 无法打开.xls 文件,不支持 xlrd - Python: Pandas read_excel cannot open .xls file, xlrd not supported Pandas read_excel(格式 xls) - Pandas read_excel (format xls) Pandas read_excel 在读取 excel 文件时给出 yes no - Pandas read_excel gives yes no while reading an excel file 使用 read_excel 和转换器将 Excel 文件读入 Pandas DataFrame 会产生对象类型的数字列 - Using read_excel with converters for reading Excel file into Pandas DataFrame results in a numeric column of object type 在 Python pandas 中使用 `read_excel` 读取空单元格 - Reading in Empty Cells with `read_excel` in Python pandas Python循环遍历excel文件并使用pandas read_excel函数一一读取 - Python Loop through excel file and and read each one by one using pandas read_excel function python pandas read_excel返回一个AssertionError:导入带有图像的文件 - python pandas read_excel return an AssertionError: importing a file with images python pandas read_excel engine=openpyxl 不关闭文件 - python pandas read_excel engine=openpyxl not closing file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM