Untitled

mail@pastecode.io avatarunknown
plain_text
11 days ago
2.2 kB
2
Indexable
Never
def generate_ITD_LA03_Presupuestos_Ingresos(input_folder, file_name, output_folder, header, sheet_name):
    """
    Generates ITD_LH04_Presupuesto_Ingresos.xlsx files by reading Excel files in the specified import folder, filtering the data to keep only relevant information for projects,
    and exporting the results to the specified export folder. 

    Parameters:
        imput_folder (str): Path to the folder where Excel files to be imported are located.
        file_name (str): Name of the Excel files to be imported.
        header (int): Row number to use as column names in the imported Excel files.
        sheetname (str): Sheet of the Excel files to be imported.
        output_folder (str): Path to the folder where the resulting Excel files will be exported.

    Returns:
        None
    """
    presupuesto_ingresos = pd.DataFrame()
    for file in glob.glob(f'./{input_folder}/{file_name}_*.xls*'):
        df = pd.read_excel(file, header=header, sheet_name=sheet_name)
        df = add_close_years_columns(file, df)
        df = add_report_date_columns(file, df)
        presupuesto_ingresos = pd.concat([presupuesto_ingresos, df],ignore_index=True)
        
    presupuesto_ingresos = calculate_max_dates(presupuesto_ingresos)
    
    export_excel_file(output_folder, file_name+sheet_name, presupuesto_ingresos)


generate_ITD_LA03_Presupuestos_Ingresos(input_folder = "inputs_prueba/seg_operativo",
                                        file_name = "ITD_LH04_Presupuesto_Ingresos",
                                        output_folder = "outputs_prueba/seg_operativo",
                                        header = 0,
                                        sheet_name = "DW_PPTO_INGRESOS_SOL")

generate_ITD_LA03_Presupuestos_Ingresos(input_folder = "inputs_prueba/seg_operativo",
                                        file_name = "ITD_LH04_Presupuesto_Ingresos",
                                        output_folder = "outputs_prueba/seg_operativo",
                                        header = 0,
                                        sheet_name = "DW_COST_SIN_INGRESO")