import os
import pandas as pd
source_folder = r"D:\\original data"
dest_folder = r"D:\\Data_With_Time\\"
data2=pd.DataFrame()
for file in os.listdir(source_folder):
if file.startswith("abc_file") and file.endswith(".csv"):
r=file.rfind("_")
h=file[r:][9:13]
dt=file[r:][1:9]
fn=file
data= pd.read_csv("D:\\original data\\"+file+" ")
data['SHour']= h
data['SDate']= dt
data['filename']=fn
data['DATA_TRA']=data['DATA_TRA']/3000
data2=data2.append(data)
data.to_csv("D:\\updated_"+file)
data2.to_csv("D:\\combine.csv")
data3=pd.read_csv("D:\\combine.csv")
data3=data3[['Short name','Date','Hour','Tra']]
data3 = data3.query("`name of Equipment`=='PIPE'").groupby(['name','Hour']).agg({'Tra': 'sum'})
print(data3)
data3.plot(kind="bar",title='Graph')
#Comparing the columns of two CSVs files
No comments:
Post a Comment