bugfixing
This commit is contained in:
parent
18b58f3f3b
commit
535e609983
@ -3,10 +3,12 @@ import sqlite3
|
|||||||
import asyncio
|
import asyncio
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def save_as_json(symbol, data):
|
async def save_as_json(symbol, data):
|
||||||
with open(f"json/shareholders/{symbol}.json", 'w') as file:
|
with open(f"json/shareholders/{symbol}.json", 'w') as file:
|
||||||
ujson.dump(data, file)
|
ujson.dump(data, file)
|
||||||
@ -26,9 +28,16 @@ async def get_data(ticker, con):
|
|||||||
try:
|
try:
|
||||||
df = pd.read_sql_query(query_template, con, params=(ticker,))
|
df = pd.read_sql_query(query_template, con, params=(ticker,))
|
||||||
shareholders_list = ujson.loads(df.to_dict()['shareholders'][0])
|
shareholders_list = ujson.loads(df.to_dict()['shareholders'][0])
|
||||||
|
# Keys to keep
|
||||||
|
keys_to_keep = ["cik","ownership", "investorName", "changeInSharesNumberPercentage", "weight", "sharesNumber", "marketValue"]
|
||||||
|
|
||||||
|
# Create new list with only the specified keys
|
||||||
|
shareholders_list = [
|
||||||
|
{key: d[key] for key in keys_to_keep}
|
||||||
|
for d in shareholders_list
|
||||||
|
]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
#print(e)
|
||||||
shareholders_list = []
|
shareholders_list = []
|
||||||
|
|
||||||
return shareholders_list
|
return shareholders_list
|
||||||
@ -53,4 +62,4 @@ async def run():
|
|||||||
try:
|
try:
|
||||||
asyncio.run(run())
|
asyncio.run(run())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
Loading…
x
Reference in New Issue
Block a user