Skip to content

Instantly share code, notes, and snippets.

@tashrifbillah
Last active December 22, 2021 22:36
Show Gist options
  • Save tashrifbillah/cea43521588adf127cae79353ae09968 to your computer and use it in GitHub Desktop.
Save tashrifbillah/cea43521588adf127cae79353ae09968 to your computer and use it in GitHub Desktop.
Make DPdash compatible files from flow check CSVs
#!/usr/bin/env python
import pandas as pd
import sys
from os.path import abspath
filename= abspath(sys.argv[1])
# read Kevin's dataframe
df= pd.read_csv(filename)
# replace [Date,Time,UTC Offset] columns with [day,reftime,timeofday,weekday]
dfnew= pd.DataFrame(columns=['day','reftime','timeofday','weekday']+list(df.columns.values[3:]))
# insert values
dfnew.loc[0]= list([1,'','',''])+ list(df.loc[0][3:].values)
outfile= filename.split('flowcheck')[0]+ 'flowcheck-'+ 'day1to1.csv'
dfnew.to_csv(outfile, index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment