diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ee/tools/part_apply_souffle_post.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/ee/tools/part_apply_souffle_post.py b/src/ee/tools/part_apply_souffle_post.py index 6cc5f36..819bd03 100644 --- a/src/ee/tools/part_apply_souffle_post.py +++ b/src/ee/tools/part_apply_souffle_post.py @@ -21,10 +21,26 @@ def work(in_path: Path, out_path: Path, work_dir: Path): for part in in_parts: out_parts.add_entry(part, False) - mpn_csv = work_dir / "out" / "mpn.csv" + out_dir = work_dir / "out" + + # Sort the output to keep changes in the file to a minimum when the rules change. + for file in out_dir.iterdir(): + if file.name.endswith(".csv"): + with file.open("r") as f: + reader = csv.reader(f, dialect="excel-tab") + rows = sorted(reader) + + tmp = Path(str(file) + ".tmp") + with tmp.open("w") as out: + writer = csv.writer(out, dialect="excel-tab") + writer.writerows(rows) + + tmp.rename(file) + + mpn_csv = out_dir / "mpn.csv" new_facts = 0 - with (work_dir / "out" / "fact.csv").open("r") as f: + with (out_dir / "fact.csv").open("r") as f: reader = csv.reader(f, dialect="excel-tab") for uri, key, value in reader: try: |