Beispiel #1
0
def process(path_to_ini: str):
    """ Program main function """
    input_paths, output_path = load_ini(path_to_ini)
    records = Records()
    load(records, input_paths["csv"], input_paths["json"],
         input_paths["encoding"])
    records.output(output_path["fname"], output_path["encoding"])
Beispiel #2
0
empl_by_year = {}
for ticker in tickers:
    empl_by_year[ticker] = Counter([])

if os.path.isdir(empl_path):
    if os.listdir(empl_path)[0].endswith('.csv'):
        csv_parser(processor, empl_by_year, empl_path, tickers, infer_tickers, primary_skills)
    else:
        json_parser(processor, empl_by_year, empl_path, tickers, infer_tickers, primary_skills)
else:
    if empl_path.endswith('.csv'):
        print('Individual file processing supported only on json')
        sys.exit(1)
    else:
        json_parser(processor, empl_by_year, empl_path, tickers, infer_tickers, primary_skills)

#block for annual counts. 
empl_changes_lst = rec.output()
varlist = [
    "type","ticker","yrmth", "birth","gender","skill1","skill2","cntry","edu","f_elite",
    "edu_faculty","raw_skills", "job_role","depmt","ind_next","tenure","nprom"
]

empl_changes_df = pd.DataFrame(data=empl_changes_lst,columns=varlist)
empl_changes_df.to_csv(r'../outputs/' + target + '.csv', index= False)

empl_by_year = pd.DataFrame(empl_by_year).fillna(0).unstack().reset_index()
empl_by_year.columns = ["ticker", "year", "employment"]
empl_by_year.to_csv(r'../outputs/' + target + '_by_year.csv', index= False)