-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlocations.py
40 lines (30 loc) · 1023 Bytes
/
locations.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
import pyrebase
import csv
import pprint
import sys
# Function to convert a csv file to a list of dictionaries. Takes in one variable called "variables_file"
def csv_dict_list(variables_file):
# Open variable-based csv, iterate over the rows and map values to a list of dictionaries containing key/value pairs
reader = csv.DictReader(open(variables_file, 'rb'))
dict_list = []
for line in reader:
dict_list.append(line)
return dict_list
# config = {
# "apiKey" : "api",
# "authDomain" : "auth",
# "databaseURL" : "dtb",
# "projectId": "pjID",
# "storageBucket" : "sB",
# "messagingSenderId" : "ID"
# }
# firebase = pyrebase.initialize_app(config)
# db = firebase.database()
variables_file = 'LocationData.csv'
locations = csv_dict_list(variables_file)
for location in locations:
location['Key'] = location.pop('\xef\xbb\xbfKey')
# db.child("locations").push(location,None)
# users = db.child("locations").get()
for user in users.each():
print(user.val()['Website']) # users