-
Notifications
You must be signed in to change notification settings - Fork 0
/
lookup_hv.py
32 lines (25 loc) · 978 Bytes
/
lookup_hv.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
#!/usr/bin/env python3
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
# Module3 run log
SPREADSHEET_ID = '19kOYFh3UCpoBRHFm7KZPQs133jJaUSbRYCmbbW-EQ6I'
RANGE_NAME = 'RunLog!G4:J'
def get_hv_dict():
"Returns mapping of filename to drift field (kV/cm)"
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
service = build('sheets', 'v4', credentials=creds)
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId=SPREADSHEET_ID,
range=RANGE_NAME).execute()
values = result.get('values', [])
mapping = {}
for row in values:
if len(row) < 4:
continue
field, fname = row[0], row[3]
if not fname.endswith('.h5'):
continue
field = float(field) if field else 0.0
mapping[fname] = field
return mapping