Skip to content

Commit

Permalink
update reformat csv
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Troy committed Jun 5, 2024
1 parent 877871c commit 2b0e3c4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion liiatools/reformat_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def process(input):
pass
except pd.errors.ParserError:
with open(file_loc, "r") as f:
print(f"{file_loc} has extra commas")
data = f.read().splitlines()
headers_len = len(data[0].split(","))
row_no = 0
Expand All @@ -52,6 +53,6 @@ def process(input):
raise Exception(f"Non blank extra columns in {file_loc} on row: {row_no}")

if new_data:
with open(file_loc[:-4] + "_test.csv", "w", newline="") as f:
with open(file_loc, "w", newline="") as f:
csvwriter = csv.writer(f, delimiter=',')
csvwriter.writerows(new_data)

0 comments on commit 2b0e3c4

Please sign in to comment.