-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
group entities by referenced entities
- Loading branch information
1 parent
e9844b9
commit 020509f
Showing
9 changed files
with
106 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
virtuoso-opensource/ filter=lfs diff=lfs merge=lfs -text | ||
duplicated_br_from_files.csv filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
oc_meta/run/merge/find_diff_between_sparql_and_files_merge_lists.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import argparse | ||
import csv | ||
from typing import Set, List | ||
|
||
def read_csv(file_path: str) -> Set[str]: | ||
entities = set() | ||
with open(file_path, 'r') as csvfile: | ||
reader = csv.reader(csvfile) | ||
next(reader) # Skip header | ||
for row in reader: | ||
surviving_entity = row[0] | ||
merged_entities = row[1].split('; ') | ||
entities.add(surviving_entity) | ||
entities.update(merged_entities) | ||
return entities | ||
|
||
def find_differences(file_a: str, file_b: str) -> tuple[List[str], List[str]]: | ||
entities_a = read_csv(file_a) | ||
entities_b = read_csv(file_b) | ||
|
||
in_a_not_b = list(entities_a - entities_b) | ||
in_b_not_a = list(entities_b - entities_a) | ||
|
||
return in_a_not_b, in_b_not_a | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="Find differences between two CSV files.") | ||
parser.add_argument("file_a", help="Path to the first CSV file") | ||
parser.add_argument("file_b", help="Path to the second CSV file") | ||
args = parser.parse_args() | ||
|
||
in_a_not_b, in_b_not_a = find_differences(args.file_a, args.file_b) | ||
|
||
print("Entities in A but not in B:") | ||
for entity in in_a_not_b: | ||
print(entity) | ||
|
||
print("\nEntities in B but not in A:") | ||
for entity in in_b_not_a: | ||
print(entity) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.