Skip to content

Commit dbf6b50

Browse files
committed
Add the 'load_7z.sql' script to enable the loading of 'ed' module data using 7z.
1 parent d1367d7 commit dbf6b50

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
-- -------------------------------------------------------------------------------
2+
--
3+
-- Load data into the MIMICIVED schema
4+
--
5+
-- -------------------------------------------------------------------------------
6+
7+
--------------------------------------------------------
8+
-- File created - Tue 08 Jun 2023
9+
--------------------------------------------------------
10+
11+
-- To run from a terminal:
12+
-- psql "dbname=<DBNAME> user=<USER>" -v mimic_data_dir=<PATH TO DATA DIR> -f load_7z.sql
13+
14+
-- Change to the directory containing the data files
15+
\cd :mimic_data_dir
16+
17+
-- If running scripts individually, you can set the schema where all tables are created as follows:
18+
SET search_path TO mimiciv_ed;
19+
-- Restoring the search path to its default value can be accomplished as follows:
20+
-- SET search_path TO "$user",public;
21+
22+
/* Set the mimic_data_dir variable to point to directory containing
23+
all .csv files. If using Docker, this should not be changed here.
24+
Rather, when running the docker container, use the -v option
25+
to have Docker mount a host volume to the container path /mimic_data
26+
as explained in the README file
27+
*/
28+
29+
--------------------------------------------------------
30+
-- Load Data for Table diagnosis
31+
--------------------------------------------------------
32+
\echo '######################'
33+
\echo 'Copying diagnosis.....'
34+
\copy diagnosis FROM PROGRAM '7z e -so diagnosis.csv.gz' DELIMITER ',' CSV HEADER NULL ''
35+
\echo 'Table diagnosis successfully generated.'
36+
37+
--------------------------------------------------------
38+
-- Load Data for Table edstays
39+
--------------------------------------------------------
40+
\echo '###################'
41+
\echo 'Copying edstay.....'
42+
\copy edstays from PROGRAM '7z e -so edstays.csv.gz' delimiter ',' csv header NULL ''
43+
\echo 'Table edstay successfully generated.'
44+
45+
--------------------------------------------------------
46+
-- Load Data for Table medrecon
47+
--------------------------------------------------------
48+
\echo '#####################'
49+
\echo 'Copying medrecon.....'
50+
\copy medrecon from PROGRAM '7z e -so medrecon.csv.gz' delimiter ',' csv header NULL ''
51+
\echo 'Table medrecon successfully generated.'
52+
53+
--------------------------------------------------------
54+
-- Load Data for Table pyxis
55+
--------------------------------------------------------
56+
\echo '##################'
57+
\echo 'Copying pyxis.....'
58+
\copy pyxis from PROGRAM '7z e -so pyxis.csv.gz' delimiter ',' csv header NULL ''
59+
\echo 'Table pyxis successfully generated.'
60+
61+
--------------------------------------------------------
62+
-- Load Data for Table triage
63+
--------------------------------------------------------
64+
\echo '###################'
65+
\echo 'Copying triage.....'
66+
\copy triage from PROGRAM '7z e -so triage.csv.gz' delimiter ',' csv header NULL ''
67+
\echo 'Table triage successfully generated.'
68+
69+
--------------------------------------------------------
70+
-- Load Data for Table vitalsign
71+
--------------------------------------------------------
72+
\echo '######################'
73+
\echo 'Copying vitalsign.....'
74+
\copy vitalsign from PROGRAM '7z e -so vitalsign.csv.gz' delimiter ',' csv header NULL ''
75+
\echo 'Table vitalsign successfully generated.'
76+
\echo 'All tables generated.'
77+
\echo 'THE END.'

0 commit comments

Comments
 (0)