-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_gspread.py
47 lines (38 loc) · 1.22 KB
/
_gspread.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
39
40
41
42
43
44
45
46
47
'''
Instant Scope
Madelene Habib
Fluvio L Lobo Fenoglietto
'''
# Import Modules and Libraries
# ----------------------------------------------------------- #
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# Functions
# ----------------------------------------------------------- #
def setupClient():
'''
setupClient()
- Creates/opens google sheets client
'''
scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('users.json', scope)
client = gspread.authorize(creds)
return client
# ----------------------------------------------------------- #
def getColumnValues(client, filename, column):
'''
getColumnValues()
- Retrieves all values in a given row
'''
sheet = client.open( filename ).sheet1
values = sheet.col_values( column )
return values
# ----------------------------------------------------------- #
def getRowValues(client, filename, row):
'''
getRowValues()
- Retrieves all values in a given row
'''
sheet = client.open( filename ).sheet1
values = sheet.row_values( row )
return values