Skip to content

Instantly share code, notes, and snippets.

@storming0x
Last active February 14, 2024 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save storming0x/41d637fe67ab28541c4fc4bc2f2caa41 to your computer and use it in GitHub Desktop.
Save storming0x/41d637fe67ab28541c4fc4bc2f2caa41 to your computer and use it in GitHub Desktop.
check_stark.py
import os
import json
# Path to the directory containing JSON files
json_directory = "eth"
# List of identity strings to check against
identities_to_check = [
"address1",
"address2",
]
def process_files(directory):
total_amount = 0.0 # Initialize a variable to store the sum of amounts
# Loop through all files in the directory
for filename in os.listdir(directory):
if filename.endswith(".json"):
file_path = os.path.join(directory, filename)
with open(file_path, "r") as file:
data = json.load(file)
# Check each identity in the JSON file
for eligible in data.get("eligibles", []):
if eligible["identity"] in identities_to_check:
print(
f"Matching identity found: {eligible['identity']} with amount: {eligible['amount']} in file {filename}"
)
total_amount += float(
eligible["amount"]
) # Add the amount to the total
# Print the total sum of amounts at the end
print(f"Total sum of amounts for matching identities: {total_amount}")
if __name__ == "__main__":
process_files(json_directory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment