forked from mikeghen/python_api_samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_user.py
More file actions
39 lines (27 loc) · 819 Bytes
/
update_user.py
File metadata and controls
39 lines (27 loc) · 819 Bytes
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
import yaml ### install the pyyaml package
from lookerapi import LookerApi
import csv
import json
### ------- HERE ARE PARAMETERS TO CONFIGURE -------
host = ''
csv_file = ''
### ------- OPEN THE CONFIG FILE and INSTANTIATE API -------
f = open('config.yml')
params = yaml.load(f)
f.close()
my_host = params['hosts'][host]['host']
my_secret = params['hosts'][host]['secret']
my_token = params['hosts'][host]['token']
looker = LookerApi(host=my_host,
token=my_token,
secret = my_secret)
def read_csv(file):
f = open(file, 'rb')
reader = csv.reader(f)
header = reader.next()
output = [dict(zip(header, map(str, row))) for row in reader]
return output
data = read_csv(csv_file)
for i in data:
user_id = i['user_id']
looker.update_user(user_id, i)