I have a list in txt with the following data:
lista.txt
AC;12;733559;8476515;11.57
AL;27;3120494;24574808;7.87
AM;13;3483985;59779292;17.17
AP;16;669526;8265965;12.36
BA;29;14016906;154340458;11.01
CE;23;8452381;77865415;9.22
DF;53;2570160;149906319;58.49
ES;32;3514952;82121834;23.38
GO;52;6003788;97575930;16.25
MA;21;6574789;45255942;6.89
MG;31;19597330;351380905;17.93
MS;50;2449024;43514207;17.77
MT;51;3035122;59599990;19.64
PA;15;7581051;77847597;10.26
PB;25;3766528;31947059;8.48
PE;26;8796448;95186714;10.82
PI;22;3110292;22060161;7.07
PR;41;10444526;217289677;20.81
RJ;33;15989929;407122794;25.46
RN;24;3168027;32338895;10.21
RO;11;1562409;23560644;15.10
RR;14;450479;6340601;14.05
RS;43;10693929;252482597;23.61
SC;42;6248436;152482338;24.40
SE;28;2068017;23932155;11.57
SP;35;41262199;1247595927;30.24
TO;17;1383445;17240135;12.46
Where each column works, respectively: UF, CODE, POPULATION, GDP, PIBPERCAPITA
When reading this file, I need to have the program return a menu with functions like:
- View the data a specific UF
- show data for some specified UF
- Or show statistics like (average, minimum value and maximum value)
But I do not know where it goes, like reading a column. I do not know what the function in python would be. If anyone can give me a way it's already a lot of help.
I have my code like this:
#enconding utf-8
import os
import platform
plataforma = platform.system()
if (plataforma == "Windows"):
os.system("cls")
else:
os.system("clear")
arquivo = open("C:\python\lista.txt", "r")
texto = arquivo.read()
dados = []
with open("C:/python/lista.txt") as lista:
for linha in lista:
if(linha.strip() != ''):
coluna = [i.strip() for i in linha.split(' ')[:3:3]]
dados.append(coluna)
print(dados)
I can print but it all comes out messy. I got this code here on the site.