Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- path =r'C:\Users\pigna\OneDrive\Notes\Research Practicum\stuff'
- path2="C:\\Users\\pigna\\OneDrive\\Notes\\Research Practicum\\LineCSV2\\"
- allFiles = glob.glob(path + "/*.csv")
- #get lines
- df = pd.read_csv(path+"\\siri.20121106.csv",index_col=None, header=0)
- df.columns=["Timestamp","LineId","Direction","JourneyPattern","Timeframe","VehicleJourney","Operator","Congestion","Longitude","Latitude","Delay","BlockId","VehicleId","StopId","AtStop"]
- lines=df['LineId'].unique()
- #counter for naming files
- i=0
- for file_ in allFiles:
- df = pd.read_csv(file_,index_col=None, header=0)
- df.columns=["Timestamp","LineId","Direction","JourneyPattern","Timeframe","VehicleJourney","Operator","Congestion","Longitude","Latitude","Delay","BlockId","VehicleId","StopId","AtStop"]
- for line in lines:
- print(line)
- df = df[df['LineId']== line]
- df.to_csv(path2+'Line'+str(line)+'FILE'+str(i)+'.csv',index=False)
- i+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement