Skip to content

Instantly share code, notes, and snippets.

@ashutoshkrris
Created April 15, 2022 09:18
Show Gist options
  • Save ashutoshkrris/6443a8d5879cbfa0215753449d326e8f to your computer and use it in GitHub Desktop.
Save ashutoshkrris/6443a8d5879cbfa0215753449d326e8f to your computer and use it in GitHub Desktop.
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