I'm doing a tour of a database in Firebase using for cycles for a school exercise:
This is the cycle that I occupy to be able to go through the database:
from firebse_login import *
fecha = "2018-09"
lista_mañana_r = []
lista_tarde_r = []
ref = db.reference("/")
ret = ref.get()
for key in ret.items():
if key[0][0:7] == fecha:
for k in key[1].items():
if k[0] == sucursal:
for s in k[1].items():
if s[0] == "Matutino":
for t_1 in s[1].items():
for u in t_1[1].items():
if u[0]=="recargas":
if u[1] =="":
#lista_mañana_r.append(0)
a=0
else:
a=float(u[1].lstrip("$ "))
#lista_mañana_r.append(float(u[1].lstrip("$ ")))
lista_mañana_r.append(a)
elif s[0] == "Vespertino":
for t_1 in s[1].items():
for u in t_1[1].items():
if u[0] =="recargas":
if u[1] == "":
lista_tarde_r.append(0)
else:
lista_tarde_r.append(float(u[1].lstrip("$ ")))
print(lista_mañana_r)
The result I want to obtain is a list of 13 items corresponding to the item Top-ups of the morning and evening shift
To obtain the list of 13 elements, the for cycle must take into account as morning noon the summed values of 11: 00,13: 00,15: 00 for putting an example, this would imply that the general morning value of the branch Exxe1 "2018-09-10" would be for example 20 and would be the same procedure for the afternoon
I hope to ententeder, I can not attach the link to the firebase database for security