Project Details

macros.py funtion diasAntiguedad()

June 22nd 2023

"Using the datetime library, I get the current date in the format ""yyyy-mm-dd"". A path for the pending file (""Pendientes3.xlsx"") is dynamically generated using the current date. The path is constructed by combining the current date with the base path where the output files will be saved. A path is defined for the holiday file (""Festivos.xlsx""). The ""festivos.xlsx"" file containing the holiday dates is read into another DataFrame named 'df_festivos'. A function called 'asignar_antiguedad' is created that assigns a seniority tag based on the number of days. If the number of days is greater than 50, the label ""Greater than 50 days"" is assigned. If the number of days matches an entry in the 'DAYS' column of the Holiday DataFrame, the corresponding value is assigned to the 'DAYS OLD' column. If there are no matches, 'None' is returned. The 'asignar_antiguedad' function is applied to the ""Days"" column of the 'df_pend3' DataFrame, resulting from the reading of the pending file. The result is stored in a new column called ""Days Old."" Finally, the DataFrame 'df_pend3' with the new ""Days Old"" column is saved in the ""Pendientes3.xlsx"" file using the same dynamic path defined above, 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." library: sys, pandas, datetime, os, openpyxl

macros.py funtion diasAntiguedad()