I've tried several things and still can not figure out what the problem with my code is, it's a simple code. With numpy I put the txt values in the arrays array and I want to make some copies for two other lists, mensagem
and no
.
import numpy as dados
i=0
filename = input("Entre com o arquivo de dados:")
entrada = dados.genfromtxt(filename, delimiter=" ", dtype=int)
mensagem = dados.zeros((300,1))
no = dados.zeros((300,1))
for x in range(0,entrada.shape[0]):
if(entrada[x][0] in mensagem):
print("JÁ")
else:
mensagem[i]=(entrada[x][0])
no[i]=(entrada[x][1])
i=i+1
arquivo = open('mensagem.txt', 'w')
arquivo1 = open('no.txt', 'w')
for x in range(0,300):
arquivo.write(str(mensagem[x]))
arquivo.write('\n')
for x in range(0,300):
arquivo1.write(str(no[x]))
arquivo1.write('\n')
I have tried to change dtype
to int
, float
, None
.
The list no
always receives the correct value in a few places, and the rest it fills in with number 1.
It is worth mentioning that my data file that fills the list is of the format:
2.94946 14 5
2.92017 14 8
2.9751 14 19
2.97217 14 17
2.88794 14 2
2.95166 14 13
2.87769 14 12
2.95166 14 5
2.95166 14 7
2.88354 14 21
2.94653 12 24
2.99927 12 25
and has more than 300 thousand lines.
Any suggestions, or did you notice something wrong?