2019-03-09 03:55:52 +00:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
|
|
|
"metadata": {},
|
2019-03-09 04:05:35 +00:00
|
|
|
"outputs": [],
|
2019-03-09 03:55:52 +00:00
|
|
|
"source": [
|
|
|
|
"import firebase_admin\n",
|
|
|
|
"from firebase_admin import credentials\n",
|
|
|
|
"from firebase_admin import firestore\n",
|
|
|
|
"import csv\n",
|
2019-03-09 04:05:35 +00:00
|
|
|
"import numpy as np\n",
|
2019-03-09 03:55:52 +00:00
|
|
|
"# Use a service account\n",
|
|
|
|
"cred = credentials.Certificate(r'../keys/fsk.json')\n",
|
2019-03-09 04:05:35 +00:00
|
|
|
"#add your own key as this is public. email me for details\n",
|
2019-03-09 03:55:52 +00:00
|
|
|
"firebase_admin.initialize_app(cred)\n",
|
|
|
|
"\n",
|
|
|
|
"db = firestore.client()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2019-03-09 04:05:35 +00:00
|
|
|
"execution_count": 2,
|
2019-03-09 03:55:52 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"teams=db.collection('data').document('team-2022').collection(\"Midwest 2019\").get()\n",
|
|
|
|
"full=[]\n",
|
|
|
|
"tms=[]\n",
|
|
|
|
"for team in teams:\n",
|
|
|
|
" data=[]\n",
|
|
|
|
" tms.append(team.id)\n",
|
|
|
|
" reports=db.collection('data').document('team-2022').collection(\"Midwest 2019\").document(team.id).collection(\"matches\").get()\n",
|
|
|
|
" for report in reports:\n",
|
|
|
|
" data.append(db.collection('data').document('team-2022').collection(\"Midwest 2019\").document(team.id).collection(\"matches\").document(report.id).get().to_dict())\n",
|
|
|
|
" full.append(data)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
2019-03-09 04:05:35 +00:00
|
|
|
"source": []
|
2019-03-09 03:55:52 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2019-03-09 04:05:35 +00:00
|
|
|
"execution_count": 4,
|
2019-03-09 03:55:52 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"def expcsv(loc,data):\n",
|
2019-03-09 04:05:35 +00:00
|
|
|
" with open(loc+'.csv', 'w', newline='', encoding='utf-8') as csvfile:\n",
|
2019-03-09 03:55:52 +00:00
|
|
|
" w = csv.writer(csvfile, delimiter=',', quotechar=\"\\\"\", quoting=csv.QUOTE_MINIMAL)\n",
|
|
|
|
" for i in data:\n",
|
|
|
|
" w.writerow(i)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2019-03-09 04:05:35 +00:00
|
|
|
"execution_count": 12,
|
2019-03-09 03:55:52 +00:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"def keymatch(ld):\n",
|
|
|
|
" keys=set([])\n",
|
|
|
|
" for i in ld:\n",
|
|
|
|
" for j in i.keys():\n",
|
|
|
|
" keys.add(j)\n",
|
|
|
|
" kl=list(keys)\n",
|
|
|
|
" data=[]\n",
|
|
|
|
" for i in kl:\n",
|
|
|
|
" data.append([i])\n",
|
|
|
|
" for i in kl:\n",
|
|
|
|
" for j in ld:\n",
|
|
|
|
" try:\n",
|
|
|
|
" (data[kl.index(i)]).append(j[i])\n",
|
|
|
|
" except:\n",
|
|
|
|
" (data[kl.index(i)]).append(\"\")\n",
|
|
|
|
" return data\n",
|
|
|
|
"wn=[]\n",
|
|
|
|
"for i in full:\n",
|
2019-03-09 04:05:35 +00:00
|
|
|
" wn.append(np.transpose(np.array(keymatch(i))).tolist())\n",
|
2019-03-09 03:55:52 +00:00
|
|
|
"for i in range(len(wn)):\n",
|
|
|
|
" expcsv(tms[i],wn[i])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
2019-03-09 04:05:35 +00:00
|
|
|
"source": []
|
2019-03-09 03:55:52 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 3",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
"version": "3.6.5"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 2
|
|
|
|
}
|