Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 22, 2021 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/527b69d145860cda5c34c7fe9b41a139 to your computer and use it in GitHub Desktop.
Save parzibyte/527b69d145860cda5c34c7fe9b41a139 to your computer and use it in GitHub Desktop.
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