-
-
Save parzibyte/527b69d145860cda5c34c7fe9b41a139 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 crear_diccionarios(self, ruta="pokemon.csv"): | |
pokemones = {} | |
with open(ruta) as archivo: | |
next(archivo) # Descartar la primera línea | |
for linea in archivo: | |
linea_como_arreglo = linea.rstrip().split(";") | |
name = linea_como_arreglo[0] | |
id = linea_como_arreglo[1] | |
sp_attack = linea_como_arreglo[2] | |
sp_defense = linea_como_arreglo[3] | |
speed = linea_como_arreglo[4] | |
ability = linea_como_arreglo[5] | |
pokemones[int(id)] = { | |
"nombre": name, | |
"puntos_ataque": int(sp_attack), | |
"puntos_defensa": int(sp_defense), | |
"puntos_velocidad": int(speed), | |
"habilidad": ability, | |
} | |
return pokemones |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment