└── csv version 2 /csv version 2: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Convert each CSV file to a JSON file. 4 | """ 5 | 6 | import json 7 | import csv 8 | import sys 9 | 10 | from urllib.request import urlopen 11 | 12 | 13 | def main(): 14 | url_template = "https://raw.githubusercontent.com/ANDRIYKOoctopus/csv-converation-info/main/{}.txt" 15 | assets = ["atom", "juno", "scrt", "neta", "osmo", "stars"] 16 | 17 | for asset in assets: 18 | json_objects = [] 19 | csv_file_url = url_template.format(asset) 20 | print(f"fetching {csv_file_url}...") 21 | csv_lines = [line.decode() for line in urlopen(csv_file_url)] 22 | for addr, _, amount in csv.reader(csv_lines[1:]): 23 | json_objects.append({"address": addr, "amount": amount.strip()}) 24 | 25 | output_filepath = f'./json/{asset}.json' 26 | print(f"writing json data to {output_filepath}...") 27 | 28 | with open(output_filepath, "w") as output_json_file: 29 | json.dump(json_objects, output_json_file) 30 | 31 | 32 | if __name__ == "__main__": 33 | sys.exit(main()) 34 | --------------------------------------------------------------------------------