diff --git a/bin/export_records.py b/bin/export_records.py index 5a55baa..9ea8882 100644 --- a/bin/export_records.py +++ b/bin/export_records.py @@ -49,18 +49,24 @@ def main(records_dir: Path): cur.execute(query) records = cur.fetchall() + if len(records) == 0: + print("No new records found.") + return + latest_timestamp: str = max(row[1] for row in records) record_file = records_dir / f"records_{latest_timestamp}.csv" with open(record_file, mode="w", newline="") as file: - writer = csv.writer(file) + writer = csv.writer(file, lineterminator="\n") writer.writerow(["threadId", "createdAt", "name", "type", "output"]) writer.writerows(records) + print("Wrote", record_file) + if __name__ == "__main__": parser = ArgumentParser() - parser.add_argument("records_dir", type=Path, default=Path("records")) + parser.add_argument("records_dir", type=Path, nargs="?", default=Path("records")) args = parser.parse_args() main(**vars(args)) diff --git a/src/csv_generator/reactome_generator.py b/src/csv_generator/reactome_generator.py index 3f304aa..b283f61 100644 --- a/src/csv_generator/reactome_generator.py +++ b/src/csv_generator/reactome_generator.py @@ -29,7 +29,7 @@ def generate_csv( data: Neo4jDict = data_fetch_func(connector) df: pd.DataFrame = pd.DataFrame(data) df["url"] = "https://reactome.org/content/detail/" + df["st_id"] - df.to_csv(csv_file_path, index=False) + df.to_csv(csv_file_path, index=False, lineterminator="\n") return str(csv_file_path)