# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# +
import pandas as pd
from datetime import datetime,date,timedelta
#generic method with utf-8
def read_df(input_fname, ext=1, path='/home/jovyan/work/input',encoding='utf-8', test_mode=False):
	#update pandas to handle thousand operators and default na strings
	df = pd.read_csv('{}/{}.csv'.format(path, input_fname) if ext else '{}/{}'.format(path, input_fname),encoding=encoding,thousands=',',parse_dates=True)
	return(df.head(5) if test_mode else df)

#generic write with no coersion
def write_df(output_data, output_fname, path='/home/jovyan/work/output',encoding='utf-8',ts=0):
	if not output_data.empty:
		output_data.to_csv('{}/{}_{}.csv'.format(path,output_fname,datetime.now().strftime('%Y%m%d %H%M%S') if ts else datetime.now().strftime('%Y%m%d')), encoding=encoding, index=False, date_format='%Y-%m-%d')
 
# -

read_df()

StarcoderdataJupyterScriptsDedupFiltered