-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we fix other/cryptocurrencies.json ? #81
Comments
RaptaG
changed the title
Can you publish two extra JSONs every day, the one with all the national currencies you have and all the cryptocurrencies you have?
Can we fix other/cryptocurrencies.json ?
Jan 20, 2024
Using a Python script generated by ChatGPT I removed all matching entries from import json
def lowercase_names(json_data):
"""Lowercases the names of each value in a JSON file."""
for key, value in json_data.items():
json_data[key] = value.lower()
return json_data
def remove_entries(json_data, names_to_remove):
"""Removes entries from a JSON file based on a list of names."""
return {key: value for key, value in json_data.items() if value not in names_to_remove}
def main():
# Read the first JSON file
with open('first_file.json', 'r') as file1:
json_data1 = json.load(file1)
# Read the second JSON file
with open('second_file.json', 'r') as file2:
json_data2 = json.load(file2)
# Lowercase names in the first JSON file
json_data1_lowered = lowercase_names(json_data1)
# Get a list of lowercased names from the first JSON file
names_to_remove = list(json_data1_lowered.values())
# Remove entries from the second JSON file based on the names
result_json_data = remove_entries(json_data2, names_to_remove)
# Write the result to a new file
with open('result_file.json', 'w') as result_file:
json.dump(result_json_data, result_file, indent=2)
if __name__ == "__main__":
main() The output showed that:
I will make a Pull Request fixing these issues, I would love if you reviewed it! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We already have
other/currencies.json
butother/cryptocurrencies.json
has more currencies that the ones included. Could we fixother/cryptocurrencies.json
to only include the currencies that the API has?Then, we instruct in #40 to update
other/cryptocurrencies.json
as wellThe text was updated successfully, but these errors were encountered: