In [1]:
import pandas as pd
import os,sys,inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
import loadOSCdata
import pandas as pd
import numpy as np
import geopandas as gpd
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
def choose_method():
method=raw_input()
control=0
while (control==0):
if method=='csv':
print ''
print('great')
print ('your data have to be stored in a csv with these two columns')
print ('user_id,trip_id')
print 'now, give me the path to your file'
print 'the path must be a string without apostrophes'
trips=csv_method()
control=1
if method=='manually':
trips = manually()
control=1
if (method!='csv' and method!='manually'):
print 'please, type again'
method=raw_input()
return trips
In [3]:
def manually():
print ''
print 'great, lets start'
print 'give me your user_id'
user=raw_input()
user=check_id(user)
values=trip_id()
userlis=[]
userlis.append(user)
userlis=userlis*len(values)
trips=pd.DataFrame()
trips['user_id']=userlis
trips['trip_id']=values
return trips
In [4]:
def check_id(user):
return user
In [5]:
def trip_id():
trips=[]
control=1
print 'now type your trips'
print 'to stop the insertions, type stop'
k=1
while (control!='stop'):
print ('trip number ', k)
trip=raw_input()
trips.append(trip)
k=k+1
if trip==0:
print 'yo'
control=trip
del trips[-1]
return trips
In [6]:
def csv_method():
control=0
while control==0:
location=raw_input()
try:
trips=pd.read_csv(location)
control=1
except 'File d does not exist':
print 'type again your path'
return trips
In [7]:
def hi_function():
print 'hi, ready to process your trip data? \n type yes/no'
check=raw_input()
control=0
while (control==0):
if check=='no':
print ''
print('ok, than see you soon \n')
control=1
if check!='no' and check!='yes':
print 'please, type again'
check=raw_input()
if check=='yes':
print ''
print 'do you want to type your user id and your trips id manually'
print 'or do you want to upload them as a csv?'
print ''
print 'type manually/csv'
trips_lis=choose_method()
control=1
return trips
In [8]:
def save_user_trip(df):
return
In [ ]:
def save_final_df(df):
return
In [9]:
trips=hi_function()
save_user_trip(trips)
bikeshp=gpd
buffersbike=gpd
for i in trips['trip_id']:
#do we want to save a csv_file with raw data?
data=loadOSCdata.downloadData(i)
data=loadOSCdata.snapToBikelane(bikeshp,buffersbike,data)
save_final_df(data)
In [ ]:
In [ ]:
save_the_trip(trips)