简体   繁体   中英

Read table data from Excel file with python

I currently have an Excel workbook with some graphs (charts?). 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". These values are nowhere else in the file.

I would like to access these values programmatically with Python. I tried things like xlrd, but it seems xlrd ignores graphical elements. 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. But i used to read normal excel with following code. 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM