[英]Read table data from Excel file with python
I currently have an Excel workbook with some graphs (charts?). 我目前有一个带有一些图形的Excel工作簿(图表?)。 The graphs are plotted from numerical values.
这些图是根据数值绘制的。 I can access the values in LibreOffice if I right click on the graph and select "Data table".
如果右键单击图形并选择“数据表”,则可以访问LibreOffice中的值。 These values are nowhere else in the file.
这些值在文件中没有其他位置。
I would like to access these values programmatically with Python. 我想使用Python以编程方式访问这些值。 I tried things like xlrd, but it seems xlrd ignores graphical elements.
我尝试了类似xlrd的操作,但是xlrd似乎忽略了图形元素。 When I run it on my workbook I only get empty cells back.
当我在工作簿上运行它时,我只会得到空单元格。
Have you ever encountered this issue? 您是否遇到过此问题?
Sadly I cannot provide the file as it is confidential. 遗憾的是我无法提供该文件,因为它是机密文件。
I never worked with graphical excel file. 我从未使用过图形化的Excel文件。 But i used to read normal excel with following code.
但是我以前用以下代码阅读普通的excel。 have you tried this?
你尝试过这个吗?
import xlrd
file = 'temp.xls'
book = xlrd.open_workbook(file)
for sheet in book.sheets():
#to check columns in sheet
if sheet.ncols:
#row values
row_list = sheet.row_values
for value in row_list:
print(value)
import pandas as pd
df = pd.read_excel('path/name_of_your_file.xlsx')
print(df.head())
You should have a dataframe (df) to play with in python! 您应该有一个可在python中玩的数据框(df)!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.