Created
March 11, 2023 17:26
-
-
Save hoffrocket/ddf10d3e1e189e32277b792e0cc26d2a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!python | |
import requests | |
import csv | |
if __name__ == '__main__': | |
""" | |
FDIC dividends api returns a json list of objects like this: | |
{ | |
"inst_drr_web_id": 2148, | |
"inst_fin": "10011", | |
"inst_name": "THE COLUMBIAN BANK AND TRUST COMPANY", | |
"inst_closed_date": "2008-08-22T00:00:00.000Z", | |
"divd_type": "FINAL", | |
"rcvr_clm_prty_typ": "DEPOSITOR", | |
"rcvr_clm_divd_py_pct": "0.00505", | |
"rcvr_clm_divd_tot_py_pct": "0.35493", | |
"rcvr_clm_divd_py_dte": "2023-01-19T00:00:00.000Z", | |
"inst_inet_url_addr": "https://www.fdic.gov/bank/individual/failed/columbian.html", | |
"inst_divd_cmnt_txt": "" | |
} | |
""" | |
dividend_url = "https://closedbanks.fdic.gov/div-funds/api/dividends" | |
dividends_json = requests.get(dividend_url).json() | |
with open('dividends.csv', 'w', newline='') as csvfile: | |
fieldnames = ['inst_drr_web_id', 'inst_fin', 'inst_name', 'inst_closed_date', 'divd_type', 'rcvr_clm_prty_typ', 'rcvr_clm_divd_py_pct', 'rcvr_clm_divd_tot_py_pct', 'rcvr_clm_divd_py_dte', 'inst_inet_url_addr', 'inst_divd_cmnt_txt'] | |
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) | |
writer.writeheader() | |
for dividend in dividends_json: | |
writer.writerow(dividend) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment