Iterar sobre diccionarios
Una vez que se cargan datos JSON en un diccionario, puedes aprovechar las herramientas incorporadas de Python para iterar por sus claves y valores.
El archivo "nested_school_scores.json" se ha leído en un diccionario almacenado en la variable raw_testing_scores, que tiene el siguiente formato:
{
"01M539": {
"street_address": "111 Columbia Street",
"city": "Manhattan",
"scores": {
"math": 657,
"reading": 601,
"writing": 601
}
}, ...
}
Este ejercicio forma parte del curso
ETL and ELT con Python
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
raw_testing_scores_keys = []
# Iterate through the keys of the raw_testing_scores dictionary
for school_id in raw_testing_scores.____():
# Append each key to the raw_testing_scores_keys list
raw_testing_scores_keys.append(____)
print(raw_testing_scores_keys[0:3])