tra-analysis/data analysis/test.py

84 lines
2.7 KiB
Python
Raw Normal View History

2019-03-21 01:18:55 +00:00
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
import csv
import numpy as np
# Use a service account
cred = credentials.Certificate('keys/keytemp.json')
#add your own key as this is public. email me for details
firebase_admin.initialize_app(cred)
db = firestore.client()
teams=db.collection('data').document('team-2022').collection("Central 2019").get()
full=[]
tms=[]
for team in teams:
data=[]
tms.append(team.id)
reports=db.collection('data').document('team-2022').collection("Central 2019").document(team.id).collection("matches").get()
for report in reports:
data.append(db.collection('data').document('team-2022').collection("Central 2019").document(team.id).collection("matches").document(report.id).get().to_dict())
full.append(data)
2019-03-21 02:36:49 +00:00
#print(full)
2019-03-21 01:18:55 +00:00
quant_keys = []
list_teams = ["2022", "16", "2451"]
out = []
2019-03-21 03:15:31 +00:00
#temp = []
2019-03-21 01:18:55 +00:00
var = []
2019-03-21 03:15:31 +00:00
measured_vars_total = []
team_out = {}
2019-03-21 01:18:55 +00:00
for i in range(len(full)):
for j in range(len(full[i])):
for key in list(full[i][j].keys()):
2019-03-21 02:36:49 +00:00
2019-03-21 01:18:55 +00:00
if "Quantitative" in key:
quant_keys.append(key)
if full[i][j].get(key).get('teamDBRef')[5:] in list_teams:
2019-03-21 02:36:49 +00:00
var = []
2019-03-21 03:15:31 +00:00
measured_vars = []
2019-03-21 02:36:49 +00:00
for k in range(len(list(full[i][j].get(key).keys()))):
individual_keys = list(full[i][j].get(key).keys())
#print(individual_keys)
2019-03-21 03:15:31 +00:00
measured_vars.append(individual_keys[k])
2019-03-21 02:36:49 +00:00
var.append(full[i][j].get(key).get(individual_keys[k]))
2019-03-21 03:15:31 +00:00
team_out[full[i][j].get(key).get('teamDBRef')] = var
measured_vars_total.append(measured_vars)
#temp.append(var)
2019-03-21 02:36:49 +00:00
2019-03-21 03:15:31 +00:00
out.append(var)
print(quant_keys)
print(measured_vars_total)
print(team_out)
temp = []
2019-03-21 02:36:49 +00:00
2019-03-21 03:15:31 +00:00
#for i in range(len(measured_vars)):
#for j in range(len)
2019-03-21 02:36:49 +00:00
#for k in range(len(list(full[i][j].get(key).keys()))):
# ind_keys = list(full[i][j].get(key).keys())
# print(ind_keys)
# print(k)
# print(ind_keys[k])
# print(full[i][j].get(key).get('teamDBRef')[5:])
# print(list_teams.index(full[i][j].get(key).get('teamDBRef')[5:]))
# print(full[i][j].get(key))
# var[list_teams.index(full[i][j].get(key).get('teamDBRef')[5:])].append( full[i][j].get(key).get(ind_keys[k]) )
#print(var)
2019-03-21 01:18:55 +00:00
2019-03-21 02:36:49 +00:00
#print(quant_keys)