-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSheetReader.py
More file actions
38 lines (25 loc) · 1.36 KB
/
SheetReader.py
File metadata and controls
38 lines (25 loc) · 1.36 KB
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
import gspread
import re
from oauth2client.service_account import ServiceAccountCredentials
def get_not_set_raiders():
# use creds to create a client to interact with the Google Drive API
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('service.json', scope)
client = gspread.authorize(creds)
doc = client.open_by_url('https://docs.google.com/spreadsheets/d/1n3PlGK2lqQYJng2PTO9MBuiVnqzP8RigzzooCOiZHYw/edit#gid=64379218')
sheets = doc.worksheets()
# Assumes that the current sheet is the second to last one TODO: Make it more robust
sheet = sheets[-2]
# Returns a list of raiders who have not set their Thursday and Sunday statuses yet
#
# Find locations of mandatory raid signups
thur = sheet.find(re.compile("Thursday", re.IGNORECASE))
sun = sheet.find(re.compile("Sunday", re.IGNORECASE))
all_raiders = [r for r in sheet.get_all_values()[2:-1] if '(Social)' not in r[0]]
# Create list of raiders that have not set thursday and sunday
not_set_raiders = [r for r in all_raiders if r[thur.col-1] == 'Not Set' or r[sun.col-1] == 'Not Set']
# Return list of names for all raiders who have not set attendance
return ([x[0] for x in not_set_raiders], sheet.title)
if __name__ == '__main__':
names, title = get_not_set_raiders()
print(names, title)