-
-
Save parzibyte/1da14ea4d91cc010766b90d842df0203 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def obtener_diccionario_segun_csv(): | |
pokemones = {} | |
with open(ARCHIVO_POKEMON_DATA, "r") as archivo: | |
for linea in archivo: | |
columnas = linea.split(",") | |
nombre = columnas[0] | |
puntos_de_vida = int(columnas[1]) | |
puntos_de_ataque = int(columnas[2]) | |
puntos_de_defensa = int(columnas[3]) | |
movimientos_posibles = columnas[4].split(";") | |
# Ahora que ya lo tenemos parseado, lo agregamos al diccionario | |
pokemones[nombre] = { | |
"puntos_de_vida": puntos_de_vida, | |
"puntos_de_ataque": puntos_de_ataque, | |
"puntos_de_defensa": puntos_de_defensa, | |
"movimientos_posibles": movimientos_posibles, | |
} | |
return pokemones | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment