import csv from io import StringIO texto = 'unidades\n3\n' fila = next(csv.DictReader(StringIO(texto))) print(int(fila['unidades']))