Select Git revision
matrices.py
-
martiivGylden authoredmartiivGylden authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
matrices.py 3.11 KiB
import pandas as pd
import ERFormatConstants as const
def parseTable(df):
cols = [const.Er_ID, const.Bowtie_ID, const.Metric_ID, const.Metric_Name, const.Value, const.Measure_date, const.Frequency ,const.Measurement_guide]
table = df.loc[df[const.Name]=='Table'] # Defines the table
matrics = pd.DataFrame(columns=cols)
# ! Parsing the first row of the table which has a fucked structure because lucidchart is garbage : )
erID1 = table[const.textArea4].item() # Define the ER ID
BowTieID1 = table[const.textArea5].item() # Define the Bowtie ID
MetricID1 = table[const.textArea6].item() # Define the Metric ID
MetricName1 = table[const.textArea11].item() # Define the Metric Name
Value1 = table[const.textArea14].item() # Define the Value
MeasureDate1 = table[const.textArea17].item() # Define the Measure Date
Frequency1 = table[const.textArea20].item() # Define the Frequency
Guide1 = table[const.textArea23].item() # Define the Measurement guide
matrics.loc[0] = erID1, BowTieID1, MetricID1, MetricName1, Value1, MeasureDate1, Frequency1, Guide1
erID2 = table[const.textArea7].item() # Define the ER ID
BowTieID2 = table[const.textArea8].item() # Define the Bowtie ID
MetricID2 = table[const.textArea9].item() # Define the Metric ID
MetricName2 = table[const.textArea12].item() # Define the Metric Name
Value2 = table[const.textArea15].item() # Define the Value
MeasureDate2 = table[const.textArea18].item() # Define the Measure Date
Frequency2 = table[const.textArea21].item() # Define the Frequency
Guide2 = table[const.textArea24].item() # Define the Measurement guide
matrics.loc[1] = erID2, BowTieID2, MetricID2, MetricName2, Value2, MeasureDate2, Frequency2, Guide2
matricsIndex = 1
for i in range(25, len(table.columns), 8):
if pd.isnull(table["Text Area "+str(i)].item()) == True:
break
erID = table["Text Area "+str(i)].item() # Define the ER ID
BowTieID = table["Text Area "+str(i+1)].item() # Define the Bowtie ID
MetricID = table["Text Area "+str(i+2)].item() # Define the Metric ID
MetricName = table["Text Area "+str(i+3)].item() # Define the Metric Name
Value = table["Text Area "+str(i+4)].item() # Define the Value
MeasureDate = table["Text Area "+str(i+5)].item() # Define the Measure Date
Frequency = table["Text Area "+str(i+6)].item() # Define the Frequency
Guide = table["Text Area "+str(i+7)].item() # Define the Measurement guide
series = pd.Series([erID, BowTieID, MetricID, MetricName, Value, MeasureDate, Frequency, Guide])
matrics.loc[matricsIndex] = erID, BowTieID, MetricID, MetricName, Value, MeasureDate, Frequency, Guide
matricsIndex += 1
print(matrics)