-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsheets.py
40 lines (36 loc) · 1.36 KB
/
sheets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from pprint import pprint
#change
client = ''
scope = ''
creds = ''
#initialize Spreadsheet Database
def initSheets():
global client
global creds
global scope
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json",scope)
client = gspread.authorize(creds)
#Get information of clients that are matched with driver X, the driver gives these clients the ride
def getClients (driverName):
long =[]
lat =[]
address =[]
destLong =[]
destLat =[]
destAddress = []
sheet = client.open("test").worksheet('Clients')
data = sheet.get_all_records()
drivers = sheet.col_values(9)[1:]
for i in range (0,len(drivers)):
cell = sheet.cell(i+2,9).value
if cell == driverName:
long.append(sheet.cell(i+2,7).value)
lat.append(sheet.cell(i+2,6).value)
address.append(sheet.cell(i+2,8).value)
destLat.append(sheet.cell(i+2,11).value)
destLong.append(sheet.cell(i+2,12).value)
destAddress.append(sheet.cell(i+2,13).value)
return [long,lat,address,destLat,destLong,destAddress]