-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (23 loc) · 964 Bytes
/
main.py
File metadata and controls
31 lines (23 loc) · 964 Bytes
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
from load_csvs import load_csv_files
from export_csvs import export_csv_files
import duckdb as db
def main():
# Load mimic input data files into a database
load_csv_files()
# Function loads the query before execution
def load_query(query_name):
with open(query_name, "r") as query:
create_table_query = query.read()
return create_table_query
# Load the create_patients_table.sql query
patients_table_query = load_query("create_patients_table.sql")
# Load the create_procedures_table.sql query
procedures_table_query = load_query("create_procedures_table.sql")
# Execute the sql queries
with db.connect("mimic-clinical-demo.db") as con:
con.execute(patients_table_query)
con.execute(procedures_table_query)
# Export the resultant tables from the SQL queries to CSV for import into a BI visualization tool
export_csv_files()
if __name__ == "__main__":
main()