Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. path =r'C:\Users\pigna\OneDrive\Notes\Research Practicum\stuff'
  2. path2="C:\\Users\\pigna\\OneDrive\\Notes\\Research Practicum\\LineCSV2\\"
  3. allFiles = glob.glob(path + "/*.csv")
  4.  
  5. #get lines
  6. df = pd.read_csv(path+"\\siri.20121106.csv",index_col=None, header=0)
  7. df.columns=["Timestamp","LineId","Direction","JourneyPattern","Timeframe","VehicleJourney","Operator","Congestion","Longitude","Latitude","Delay","BlockId","VehicleId","StopId","AtStop"]
  8.  
  9. lines=df['LineId'].unique()
  10.  
  11. #counter for naming files
  12. i=0
  13.  
  14. for file_ in allFiles:
  15.     df = pd.read_csv(file_,index_col=None, header=0)
  16.     df.columns=["Timestamp","LineId","Direction","JourneyPattern","Timeframe","VehicleJourney","Operator","Congestion","Longitude","Latitude","Delay","BlockId","VehicleId","StopId","AtStop"]
  17.     for line in lines:
  18.         print(line)
  19.         df = df[df['LineId']== line]
  20.         df.to_csv(path2+'Line'+str(line)+'FILE'+str(i)+'.csv',index=False)
  21.     i+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement