Skip to content

Commit e7743bf

Browse files
authored
Merge pull request #1788 from MIT-LCP/alistair/sqlite_only_load_mimic_files
Fix SQLite build using all CSV files
2 parents 563ac8a + f925c03 commit e7743bf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mimic-iv/buildmimic/sqlite/import.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
def process_dataframe(df: pd.DataFrame, subjects: t.Optional[t.List[int]] = None) -> pd.DataFrame:
5151
for c in df.columns:
5252
if c.endswith('time') or c.endswith('date'):
53-
df[c] = pd.to_datetime(df[c], format='ISO8601')
53+
df[c] = pd.to_datetime(df[c])
5454

5555
if subjects is not None and 'subject_id' in df:
5656
df = df.loc[df['subject_id'].isin(subjects)]
@@ -96,6 +96,15 @@ def main():
9696
print(f"Missing tables: {missing_tables}")
9797
sys.exit()
9898

99+
# subselect to only tables in the above list
100+
ignored_files = set([f for f, t in zip(data_files, tablenames) if t not in _MIMIC_TABLES])
101+
data_files = [f for f, t in zip(data_files, tablenames) if t in _MIMIC_TABLES]
102+
tablenames = [t for t in tablenames if t in _MIMIC_TABLES]
103+
print(f"Importing {len(tablenames)} files.")
104+
105+
if ignored_files:
106+
print(f"Ignoring {len(ignored_files)} files: {ignored_files}")
107+
99108
pt = None
100109
subjects = None
101110
if args.limit > 0:

0 commit comments

Comments
 (0)