performance_outcomes = [ outcome.strip("'") for outcome in performance_outcomes.split(';') ] if project_type == params.ptype_commdesign: # for community design report, user does not choose which performance outcomes to include. all are included. performance_outcome_sheets = params.perf_outcomes_commdesign else: #convert user-entered perf outcomes to the corresponding excel sheet names performance_outcome_sheets = [ params.perf_outcomes_dict[outcome] for outcome in performance_outcomes ] out_report = utils.Publish(out_df, template_xl, params.xlsx_import_sheet, output_xl, project_fc, project_type, performance_outcome_sheets, proj_name) if include_pdf: try: outputs = out_report.make_pdf( ) # successful run returns tuple ("ok", output PDF file, output excel file) # if fail, returns tuple ("fail", <error message>) out_status = outputs[0] if out_status == params.msg_ok: out_excel = outputs[1] out_pdf = outputs[2] arcpy.SetParameterAsText(9, out_excel) arcpy.SetParameterAsText(10, out_pdf)
for col in df_aggvals.columns if col != region_headname } for year in analysis_years: df_agg_yr = df_aggvals[df_aggvals[col_aggvals_year] == year] # filter to specific year df_agg_yr = df_agg_yr[ cols_ctype_reg] # only include community types for community types that project is in df_agg_yr = df_agg_yr.rename(columns={project_ctype: 'CommunityType'}) df_agg_yr = df_agg_yr.rename(columns={ col: '{}_{}'.format(col, year) for col in list(df_agg_yr.columns) }) out_df = out_df.join(df_agg_yr) arcpy.AddMessage("Writing to XLSX and making PDF report...") out_report = utils.Publish(out_df, template_xl, p.xlsx_import_sheet, output_xl, performance_outcomes, None, proj_name) #out_report = utils.Publish(out_df, template_xl, p.xlsx_import_sheet, output_xl, performance_outcomes, # p.map_list_csv, proj_name) out_report.make_pdf() # utils.overwrite_df_to_xlsx(out_df, p.template_xlsx, output_xl, p.xlsx_import_sheet) # utils.excel2pdf(output_xl, report_pdf, p.sheets_to_pdf) arcpy.AddMessage("success!")
aggval_headers = { col: 'CommunityType' for col in df_aggvals.columns if col != region_headname } for year in analysis_years: df_agg_yr = df_aggvals[df_aggvals[col_aggvals_year] == year] # filter to specific year df_agg_yr = df_agg_yr[ cols_ctype_reg] # only include community types for community types that project is in df_agg_yr = df_agg_yr.rename(columns={project_ctype: 'CommunityType'}) df_agg_yr = df_agg_yr.rename(columns={ col: '{}_{}'.format(col, year) for col in list(df_agg_yr.columns) }) out_df = out_df.join(df_agg_yr) arcpy.AddMessage("Writing to XLSX and making PDF report...") out_report = utils.Publish( out_df, template_xl, p.xlsx_import_sheet, output_xl, performance_outcomes, None, proj_name) #map_key_csv can be p.map_list_csv instead of None out_report.make_pdf() # utils.overwrite_df_to_xlsx(out_df, p.template_xlsx, output_xl, p.xlsx_import_sheet) # utils.excel2pdf(output_xl, report_pdf, p.sheets_to_pdf) arcpy.AddMessage("success!")
proj_fc = arcpy.GetParameterAsText(0) xlt_in = r"\\arcserver-svr\D\PPA_v2_SVR\PPA2\Input_Template\XLSX\PPA_Template_ArterialExp.xlsx" csv_in = r"\\arcserver-svr\D\PPA_v2_SVR\Tests\sample_ppa_raw_output.csv" proj_type = params.ptype_arterial out_dir = arcpy.env.scratchFolder xl_out = os.path.join(out_dir, "OutputTest{}.xlsx".format(int(time.clock()))) df_test = pd.read_csv(csv_in, index_col='data_item') sheets_to_pdf = ['1ReduceVMT', '3Multimodal'] output = utils.Publish(df_test, xlt_in, params.xlsx_import_sheet, xl_out, proj_fc, proj_type, xlsheets_to_pdf=sheets_to_pdf, proj_name='UnnamedProject') print('making PDF...') results = output.make_pdf() arcpy.SetParameterAsText(1, results[1]) arcpy.SetParameterAsText(2, results[2]) # print(results[0]) # print(results[1])