-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactive_exclusions.py
More file actions
51 lines (46 loc) · 1.57 KB
/
active_exclusions.py
File metadata and controls
51 lines (46 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import pandas as pd
import numpy as np
from datetime import datetime
from tkinter.filedialog import askopenfilename
from tkinter.filedialog import asksaveasfilename
def main():
# import the exclusion report and read it into a pandas data frame
df = pd.read_excel(askopenfilename(title="Open the Exclusion Report"))
# create the relevant date variables
today = datetime.today().date()
# filter out exclusions that happened more than 6 months ago the exclusion
# was not agency wide, and/or the exclusion was not created by the day center
df_2 = df[
(
(
df["Infraction Provider"].str.contains("Day") |
df["Infraction Provider"].str.contains("Agency")
)
) |
(
df["Infraction Banned End Date"].isna()
)
]
# write the final report to excel and exit
intial_file_name = "Exclusion Report {}.xlsx".format(today)
writer = pd.ExcelWriter(
asksaveasfilename(
title="Save the Recent Exclusion from the Resource Center Report",
defaultextension=".xlsx",
initialfile=intial_file_name
),
engine="xlsxwriter"
)
df_2[[
"Client Uid",
"Client First Name",
"Client Last Name",
"Infraction Provider",
"Infraction Banned Start Date",
"Infraction Banned End Date",
"Infraction Banned Code",
"Infraction Type"
]].to_excel(writer, sheet_name="Resource Center Exclusions", index=False)
writer.save()
if __name__ == "__main__":
main()