简体   繁体   English

使用python从Excel文件中读取表数据

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

相关问题 如何从excel文件和python中具有复杂表结构的数据中读取和识别颜色编码数据(字体和背景)? - How to read and identify color coded data(font and background) from excel file and data with complex table structure in python? 从Excel读取数据并以CSV格式写入文件-Python - Read data from excel and write as CSV format to a file - Python - 从excel文件中读取数据并在python中以json格式返回响应 - - read data from excel file and return response in json format in python Selenium python 未从 excel 中读取数据后,我将一些新的登录数据添加到 ZBF57C906FA7D2BB856D07 文件72E41 - Selenium python not read data from excel after i add some new login data into the excel file 使用python将数据从csv文件读取到word文档作为表格 - read data from csv file to word document as a table using python Python脚本从文件读取数据并将其存储在mysql表中 - Python script to read data from a file and store it in mysql table 如何在 python 中读取 json 数据 excel 文件 - how to read json data excel file in python 来自Excel文件和Python的数据 - Data from Excel File and Python 如何在 Python 3 中从 AWS 读取 Excel 文件? - How to read Excel File from AWS in Python 3? Python从Excel文件中读取日期字符串 - Python read datestring from excel file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM