16 lines
No EOL
579 B
Python
16 lines
No EOL
579 B
Python
import os
|
|
import pandas as pd
|
|
import numpy as np
|
|
from scraper.top100_extractor import programming_crime_list
|
|
COMPANIES_CSV_PATH: str = 'scraper/companies.csv'
|
|
|
|
|
|
def get_companies(root_dir: str) -> list[dict]:
|
|
"""
|
|
reads the companies.csv file and returns it as a JSON-ifiable object
|
|
to return to the frontend.
|
|
"""
|
|
df = pd.read_csv(os.path.join(root_dir, COMPANIES_CSV_PATH), index_col='ticker')
|
|
tickers = pd.Series(programming_crime_list)
|
|
df = df.loc[df.index.isin(tickers), :]
|
|
return df.reset_index().replace({ np.nan: None }).to_dict('records') |