I'm trying to write a python script to collect data from an excel table (see picture) with a lot of spreadsheets and data in in.
The table contains mole fraction of species in each column at different pressure in each row.
I will need just tables named with "..._end_point_vs_parameter". PFRC1... represents mole fraction results at 100°C so i have to consider up to PFRC13_end_point_vs_parameter (700°C).
My script is currently working just for one row and one spreadsheet:
import pandas as pd
species = ["O2","CO","CO2","CH4","H2O","C2H6","CH2O","C2H4","CH3OH","C2H2","CH3COCH3","C3H8","C3H6","IC4H8","IC8H18"]
reactors = ["PFRC1","PFRC2","PFRC3","PFRC4","PFRC5","PFRC6","PFRC7","PFRC8","PFRC9","PFRC10", "PFRC11", "PFRC12", "PFRC13"]
xlsfile = pd.ExcelFile('PLUG_MehlPRF2011_1000sccm.xlsx')
sheets = xlsfile.sheet_names
frames = dict.fromkeys(sheets)
output =pd.DataFrame(index=reactors)
for sheet in sheets:
df = xlsfile.parse(sheet_name=sheet)
frames[sheet] = df
#for reactor in reactors:
# [frame for key, frame in frames.items() if reactor in key]
for compound in species:
profile=pd.Series(name=compound, index=reactors)
for reactor in reactors:
columname = " Mole_fraction_"+compound+"_"+reactor+"_()"
for key in frames:
df=frames[key]
if columname in df.columns:
profile[reactor]=df[columname].iloc[-1]
output[compound]=profile
output.to_excel("profiles.xlsx")
How can i collect data from different spreadsheads and for each defined column name all data in it. I need to somehow summarize those data into this.