Skip to content

Commit

Permalink
Merge pull request #67 from will-moore/load_zarr_stats_temp_csv
Browse files Browse the repository at this point in the history
load_zarr_stats.py writes temp.csv then output.csv when done
  • Loading branch information
will-moore authored Oct 25, 2024
2 parents f3dcfaa + 2888582 commit 7a6527e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions samples/load_zarr_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def load_zarr(zarr_url, average_count=5):
args = parser.parse_args()

csv_name = args.csv_name
temp_csv = csv_name.replace(".csv", "_temp.csv")
output_csv = csv_name.replace(".csv", "_output.csv")

column_names = []
Expand Down Expand Up @@ -238,7 +239,7 @@ def load_zarr(zarr_url, average_count=5):
column_data.append(row)

# in case script fails mid-way, we write as we go...
with Path(output_csv).open("a", newline="") as outfile:
with Path(temp_csv).open("a", newline="") as outfile:
csvwriter = csv.writer(outfile, delimiter=",", quoting=csv.QUOTE_MINIMAL)
csvwriter.writerow(row)

Expand All @@ -257,8 +258,9 @@ def load_zarr(zarr_url, average_count=5):
"fbbiId",
]

with Path(output_csv).open("a", newline="") as csvfile:
# write the final output csv file...
with Path(output_csv).open("w", newline="") as csvfile:
csvwriter = csv.writer(csvfile, delimiter=",", quoting=csv.QUOTE_MINIMAL)
# csvwriter.writerow(column_names)
# for row in column_data:
# csvwriter.writerow(row)
csvwriter.writerow(column_names)
for row in column_data:
csvwriter.writerow(row)

0 comments on commit 7a6527e

Please sign in to comment.