Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SQLite build using all CSV files #1788

Merged
merged 3 commits into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion mimic-iv/buildmimic/sqlite/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
def process_dataframe(df: pd.DataFrame, subjects: t.Optional[t.List[int]] = None) -> pd.DataFrame:
for c in df.columns:
if c.endswith('time') or c.endswith('date'):
df[c] = pd.to_datetime(df[c], format='ISO8601')
df[c] = pd.to_datetime(df[c])

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

# subselect to only tables in the above list
ignored_files = set([f for f, t in zip(data_files, tablenames) if t not in _MIMIC_TABLES])
data_files = [f for f, t in zip(data_files, tablenames) if t in _MIMIC_TABLES]
tablenames = [t for t in tablenames if t in _MIMIC_TABLES]
print(f"Importing {len(tablenames)} files.")

if ignored_files:
print(f"Ignoring {len(ignored_files)} files: {ignored_files}")

pt = None
subjects = None
if args.limit > 0:
Expand Down
Loading