diff --git a/src/main.py b/src/main.py index f411378..1755c5e 100644 --- a/src/main.py +++ b/src/main.py @@ -9,12 +9,12 @@ def main(): start_time = time.time() mainFolderPath,configFileMain,hashL, xlsxList = initialisation.main() - testVar=data_import.main(mainFolderPath,configFileMain, xlsxList) - data_processing.main(testVar) + levelListM,weightListM, dimensionListM, interDimensionalListM, kripSimplifiedListM=data_import.main(mainFolderPath,configFileMain, xlsxList) + #data_processing.main(testVar) #dontforget to use hashList from src.methods import report_generator # to make global variable work - report_generator.main(mainFolderPath,configFileMain,hashL,testVar) + report_generator.main(mainFolderPath,configFileMain,len(xlsxList),levelListM,weightListM, dimensionListM, interDimensionalListM, kripSimplifiedListM) logging.info("Program ended") logging.info("Program runtime: " + f"{(time.time() - start_time):.2f}" + " seconds") diff --git a/src/methods/data_import.py b/src/methods/data_import.py index 4d601ef..830bd7e 100644 --- a/src/methods/data_import.py +++ b/src/methods/data_import.py @@ -28,15 +28,13 @@ def main(inputFolder, configFile,xlList): worksheetList = get_first_X_worksheet_names(xlList[0], len(subCompNumList)) - x=start_import(xlList, worksheetList, cC, sR,subCompNumList,cLG,lC,special_sheets_list) + levelList,weightList, dimensionList, interDimensionalList, kripSimplifiedList=start_import(xlList, worksheetList, + cC, sR,subCompNumList,cLG,lC,special_sheets_list) #print(x) - - - logging.info("M - Data import finished successfully") - return x + return levelList,weightList, dimensionList, interDimensionalList, kripSimplifiedList def number_of_comparisions(n): @@ -53,25 +51,42 @@ def start_import(pathList, worksheetList, comparisonColumn, startingRow,subCompy #levelDF = get_levels(pathList, worksheetList, levelColumn, startingRow,subCompyList) #weightDF = get_weightings(pathList, worksheetList, comparisonColumn, startingRow,subCompyList,comparisonLevelGap) - lList,wList, dimList, intList = get_data(pathList, worksheetList, levelColumn, comparisonColumn, startingRow,subCompyList,comparisonLevelGap,SSList) + lList,wList, dimList, intDimList = get_data(pathList, worksheetList, levelColumn, comparisonColumn, startingRow,subCompyList,comparisonLevelGap,SSList) #print(get_krippendorff_DF(pd.concat(wList,axis=0))) - mWL,oG=simplify_krip(3) - for i, df in enumerate(wList): - wList[i] = df.applymap(lambda x: replace_with_lists(x, oG, mWL)) - - - verticalAdd= pd.concat(wList,axis=0) #join all dataframes vertically + kripSimpleList = [] + + """ + for num in [15,13,11,9, 7, 5, 3]: + mWL, oG = simplify_krip(num) + for i, df in enumerate(wList): + wList[i] = df.applymap(lambda x: replace_with_lists(x, oG, mWL)) + kripSimpleList.append(wList.copy()) + + concatKripSimpleList = concat_dataframes(kripSimpleList) + resultKripSimpleList = [] + for df in concatKripSimpleList: + resultKripSimpleList.append(get_krippendorff_DF(df)) + + print (resultKripSimpleList) + """ + #verticalAdd= pd.concat(wList,axis=0) #join all dataframes vertically #print(get_krippendorff_DF(verticalAdd)) #print(get_krippendorff_DF(pd.concat(lList,axis=0))) - return lList + return lList , wList, dimList, intDimList, kripSimpleList + +def concat_dataframes(list_of_lists): + concatenated_dfs = [] + for dfs in list_of_lists: + concatenated_dfs.append(pd.concat(dfs)) + return concatenated_dfs def get_data(pathList, worksheetList, levelColumn, weightColumn, startingRow, subCompyList, comparisonLevelGap,sSL): logging.info("Level and weight and special sheete import started") levelList = [pd.DataFrame() for _ in range(len(worksheetList))] weightList = [pd.DataFrame() for _ in range(len(worksheetList))] - dimensionList = [] + dimensionList = pd.DataFrame() interdimensionalList = [] for filePath in pathList: @@ -89,7 +104,8 @@ def get_data(pathList, worksheetList, levelColumn, weightColumn, startingRow, su sheet = xl.parse(sheet_name=sSL[0][0], skiprows=sSL[0][2]-2, usecols=sSL[0][1], nrows=sSL[0][3]-sSL[0][2]+1, names=[filename]) sheet = sheet.applymap(lambda x: round(x, 4)) - dimensionList.append(sheet) + dimensionList = pd.concat([dimensionList, sheet], axis=1) + #dimensionList.append(sheet) sheet = xl.parse(sheet_name=sSL[1][0], skiprows=sSL[1][2]-2, usecols=sSL[1][1], nrows=sSL[1][3]-sSL[1][2]+1, names=[filename]) sheet = sheet.fillna(0) diff --git a/src/methods/report_generator.py b/src/methods/report_generator.py index e25fd4c..edb918c 100644 --- a/src/methods/report_generator.py +++ b/src/methods/report_generator.py @@ -8,16 +8,16 @@ from src.methods.data_import import subCompListy ##############Main function############## -def main(mFP,cFM,hashList,testDataframe): +def main(mFP,cFM,nList,levelListSM,weightListSM, dimensionListSM, interDimensionalListSM, kripSimplifiedListSM): logging.info("Report generation started") outFolderPath = check_output_folder(cFM.get("Settings", "outputFolder"),mFP) #check if output folder exists listDimension,combinedList=get_subsection(cFM) #get subsections and dimensions from config file - sOF=make_folder(outFolderPath,len(hashList)) #returns specific output folder - - - csv_levels(testDataframe,sOF,combinedList) #generates csv file with levels + sOF=make_folder(outFolderPath,nList) #returns specific output folder + csv_levels(levelListSM,sOF,combinedList) #generates csv file with levels + csv_sub_inputs_pre(weightListSM,sOF) #generates csv file with subdimension inputs + csv_dim_inputs_pre(dimensionListSM,sOF) #generates csv file with dimensions inputs logging.info("Report generation finished successfully") return None @@ -73,16 +73,20 @@ def get_current_time(): ##############csv generation############## -def csv_make_weights(): +def csv_sub_inputs_pre(wL,sOF): + verticalAdd= pd.concat(wL,axis=0) + outPath=os.path.join(sOF, "inputs_subdimensions_pre_transf.csv") + verticalAdd.to_csv(outPath, index=True) return None +def csv_dim_inputs_pre(dL,sOF): + outPath=os.path.join(sOF, "inputs_dimensions_pre_transf.csv") + dL.to_csv(outPath, index=True) + return None def csv_levels(df,sOF,combL): verticalAdd= pd.concat(df,axis=0) verticalAdd.index=combL - - - #newDf = pd.DataFrame(verticalAdd.values, index=combL, columns=verticalAdd.columns) - testPath=os.path.join(sOF, "levels.csv") - verticalAdd.to_csv(testPath, index=True) + outPath=os.path.join(sOF, "levels.csv") + verticalAdd.to_csv(outPath, index=True) return None \ No newline at end of file