From a7939b05d16df90606eb56ca16d3db15b220abea Mon Sep 17 00:00:00 2001 From: david marquez <98066992+davidmarquez72@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:34:48 -0500 Subject: [PATCH 1/2] Update README.md --- README.md | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 7f01de4..9af0248 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,9 @@ -To view the full details of each script, navigate to the corresponding branch. Each branch contains a detailed description and explanation of its functionality, also you can see my file .py where i apply good pracices, comments, errors handles and use of POO. Here are the branches, showcasing the complete scripts I’ve developed: +funtion noReporte() -clinicaOdonto.py, -CopyPastePlantilla.py, -CruceCentrosMedicos.py, -cruceCodigo.py, -CrucePlanoEps.py, -CruceReporte.py, -dashboard.py, -divyvencer.py, -duplicados.py, -filtro123H.py, -macros.py, -macros2.py, -pendites_ach_juntas.py, -quitar57.py, -SepararNumeroID.py, -template.py, -tildesComillas.py, -traerDato.py, -Union.py +"Using the datetime library, I get the current date in the format ""yyyy-mm-dd"". +Using the os library, the dynamic path for the ""Do Not Report (Current Date).xlsx"" and ""REPORTE_DE_GLOSAS_BH.xlsx"" file is generated +The Pandas library is then used to read the files. Since the ""Do Not Report (Current Date).xlsx"" file is manually uploaded by a person in the area, the os library is used to verify its existence. If the file doesn't exist, the same information is taken from the ""REPORTE_DE_GLOSAS_BH.xlsx"" file and saved in a new file called ""REPORTE_DE_GLOSAS_BH_1.xlsx"". +If the file exists, the records found in ""Do Not Report (Current Date).xlsx"" are deleted from the ""REPORTE_DE_GLOSAS_BH.xlsx"" file. This is done using the merge function, where the records present in both files are identified and deleted from the first. To do this, the isin() function is used to check whether the values in the 'GLOSA ID' column of 'dfrepgen' are present in the 'GLOSA ID' column of 'crossover'. The ~ operator is used to reverse the result, i.e. select all rows in 'dfrepgen' where the 'GLOSA ID' is not present in 'junction'. +Finally, the function returns a value of 2 if executed successfully. Otherwise, it returns the error line along with an explanatory message of the error." -If you'd like to see a summary in an Excel file, you'll find **portafolio.xlsx** here. It provides a detailed overview of my Python projects using pandas, available in both English and Spanish, as well as the automation projects I've developed. +librarys: sys, pandas, datetime, os From 93a4c7dd016b2c009c844c2076dd25a3322edeb1 Mon Sep 17 00:00:00 2001 From: david marquez <98066992+davidmarquez72@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:35:15 -0500 Subject: [PATCH 2/2] Add files via upload --- CruceReporte.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 CruceReporte.py diff --git a/CruceReporte.py b/CruceReporte.py new file mode 100644 index 0000000..012cae4 --- /dev/null +++ b/CruceReporte.py @@ -0,0 +1,44 @@ +import sys +import pandas as pd +from datetime import datetime +import os + +def noReporte(): + try: + + # fecha actual + current_date = datetime.now().strftime('%d%m%Y') + + # ruta dinamica + ruta_reporte = os.path.join(r'D:\MP74. Notificar Glosas Prestadores\02. Inputs', f'No reportar {current_date}.xlsx') + + # lee archivo de archivo generado + dfrepgen = pd.read_excel(r"D:\MP74. Notificar Glosas Prestadores\04. Plantillas\REPORTE_DE_GLOSAS_BH.xlsx") + + # valida si exite el archivo + if os.path.exists(ruta_reporte): + # lee archivo de input "No reportar DDMMYYYY.xlsx" + #dfrepinput = pd.read_excel(r"D:\MP74. Notificar Glosas Prestadores\02. Inputs\No reportar 17042023.xlsx") + dfrepinput = pd.read_excel(ruta_reporte) + + # cruce + cruce = pd.merge(dfrepgen, dfrepinput, on='ID GLOSA', how='inner') + + # Eliminar los registros encontrados en el reporte1 + reporte1_sin_cruce = dfrepgen[~dfrepgen['ID GLOSA'].isin(cruce['ID GLOSA'])] + + # Guardar los resultados en dos archivos Excel diferentes + cruce.to_excel(r"D:\MP74. Notificar Glosas Prestadores\04. Plantillas\cruce.xlsx", index=False) + reporte1_sin_cruce.to_excel(r"D:\MP74. Notificar Glosas Prestadores\04. Plantillas\REPORTE_DE_GLOSAS_BH_1.xlsx", index=False) + print("El archivo existe.") + else: + dfrepgen.to_excel(r"D:\MP74. Notificar Glosas Prestadores\04. Plantillas\REPORTE_DE_GLOSAS_BH_1.xlsx", index=False) + print("El archivo no existe.") + return 2 + except Exception as e: + exc_type, exc_value, exc_traceback = sys.exc_info() + line_number = exc_traceback.tb_lineno + e = f"Error en la linea {line_number}, {e}" + return str(e) + +print(noReporte()) \ No newline at end of file