1
I have a txt list with the following data:
txt list.
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,CODIGO, POPULACAO,PIB,PIBPERCAPITA
When reading this file, I need to get the program to return me a menu with functions like:
- View the data in a specific UF
- show the data of some specified Ufs
- Or show statistics as (average, minimum and maximum value)
I just don’t know where you’re going, how to read a column. I don’t know what the python function would be. If anyone can give me a path it’s already very helpful.
I have my code this way:
#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 comes out all messy. I got this code here on the site.
What a dough! Much simpler and more organized!
– HelloWorld
Ahhhh! Very show! I will play here. With this answer I believe I can do the third question that also asks pandas as reference. Thank you @Noobsaibot.
– Sandson Costa
If this answer solved your problem and there is no doubt left, mark it as correct/accepted by clicking on the " " that is next to it, which also marks your question as solved. If you prefer the other answer, you can mark it as correct/accepted, but only one response can be marked that way. If you still have any questions or would like further clarification, feel free to comment.
– NoobSaibot