-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import json | ||
|
||
# Load data from nodes.json | ||
with open('nodes.json') as f: | ||
data = json.load(f) | ||
|
||
# Function to remove duplicate nodes | ||
def remove_duplicates(data): | ||
seen_identifiers = set() | ||
unique_data = [] | ||
for node in data: | ||
identifier = node['identifier'] | ||
if identifier not in seen_identifiers: | ||
seen_identifiers.add(identifier) | ||
unique_data.append(node) | ||
return unique_data | ||
|
||
# Remove duplicates | ||
unique_data = remove_duplicates(data) | ||
|
||
# Check if any nodes were removed | ||
if len(unique_data) < len(data): | ||
print("Duplicate nodes removed.") | ||
|
||
# Save updated data back to nodes.json | ||
with open('nodes.json', 'w') as f: | ||
json.dump(unique_data, f, indent=4) | ||
else: | ||
print("No duplicate nodes found.") | ||
|
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 @@ | ||
json |