[英]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.