Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
appujet committed Apr 8, 2024
1 parent 975155e commit d2fc7ba
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions remove_duplicates.py
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.")

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json

0 comments on commit d2fc7ba

Please sign in to comment.