From b6b668ef8cda446a5f4949b63180da236fffa2a6 Mon Sep 17 00:00:00 2001 From: Chenglim Ear Date: Fri, 3 Nov 2023 14:48:41 -0700 Subject: [PATCH] make sure dir exists for saving v2 csv files --- download/main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/download/main.py b/download/main.py index af30c5fac..bb8742a3e 100644 --- a/download/main.py +++ b/download/main.py @@ -82,9 +82,11 @@ def main(): 'XRef_Match', ]).sample(n=20)) - elections.df.to_csv('downloads/csv/elections_v2.csv', index=False) - committees.df.to_csv('downloads/csv/committees_v2.csv', index=False) - a_contributions.df.to_csv('downloads/csv/a_contributions_v2.csv', index=False) + to_csv_dirpath = 'downloads/csv' + os.makedirs(to_csv_dirpath, exists_ok=True) + elections.df.to_csv(f'{to_csv_dirpath}/elections_v2.csv', index=False) + committees.df.to_csv(f'{to_csv_dirpath}/committees_v2.csv', index=False) + a_contributions.df.to_csv(f'{to_csv_dirpath}/a_contributions_v2.csv', index=False) ''' with engine.connect() as conn: