aboutsummaryrefslogtreecommitdiffstats
path: root/python/db_csvheader.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/db_csvheader.py')
-rw-r--r--python/db_csvheader.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/python/db_csvheader.py b/python/db_csvheader.py
index e476b305..45589009 100644
--- a/python/db_csvheader.py
+++ b/python/db_csvheader.py
@@ -11,8 +11,15 @@ if __name__ == "__main__":
)
args = parser.parse_args()
conn = dbconn("dawndb")
- with open(f"/home/serenitas/flint/{args.fname}.csv") as csvfile:
+ file_name, header_name = args.fname.split(".")
+ with open(f"/home/serenitas/flint/{header_name}.csv") as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
- with open(f"headers/bond_upload.py", "w") as template_file:
- template_file.write(f"{args.fname}={row}")
+ try:
+ with open(f"headers/{file_name}.py", "a") as template_file:
+ template_file.write(f"\n{header_name}={row}")
+ except:
+ with open(f"headers/{file_name}.py", "w") as template_file:
+ template_file.write(f"{header_name}={row}")
+ csvfile.close()
+ break