Last active
February 14, 2024 18:03
-
-
Save storming0x/41d637fe67ab28541c4fc4bc2f2caa41 to your computer and use it in GitHub Desktop.
check_stark.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
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