Created
April 15, 2022 09:18
-
-
Save ashutoshkrris/6443a8d5879cbfa0215753449d326e8f to your computer and use it in GitHub Desktop.
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 json | |
def write_to_json(data: dict) -> None: | |
data_list = [] | |
for i in range(TOTAL_PERSONS): | |
temp = { | |
"Rank": data["ranks"][i], | |
"Name": data["names"][i], | |
"Link": f"https://www.bloomberg.com/billionaires/{data['links'][i]}", | |
"Total net worth($)": data["worths"][i], | |
"$ Last change": data["last_changes"][i], | |
"$ YTD change": data["ytds"][i], | |
"Country/Region": data["countries"][i], | |
"Industry": data["industries"][i] | |
} | |
data_list.append(temp) | |
with open(f"top-{TOTAL_PERSONS}-persons.json", "w") as json_file: | |
json.dump(data_list, json_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment