3
Hello, I need to make a python algorithm that reads a text file .csv which contains literally 5 million numbers and I need this algorithm to tell me which is the smallest and which is the largest number on the list. Now, the problems:
I used this code to open the list in python:
import csv
lista = open('lista.csv', 'r') read:
csv.reader(lista)
for linha in reader:
print (linha)
It works normal, but to present the largest and the smallest, it would be this:
import csv
lista = open('lista.csv', 'r') reader:
csv.reader(lista)
for linha in reader:
print linha
menor = min(linha)
maior = max(linha)
print (menor, maior)
The algorithm works, the real problem is that it appears that the smallest value is null and the greatest value is -83422495.2710933
We have already tried to put separate (an algorithm for higher number and one for the lower number) and no use, we have also tried to take out the 'for' and it does not work...
I wanted to know if there’s another way to do it or if we’re missing it... I’d like to thank you very much.
I think there’s only one sample of csv missing to see how the values are arranged, if it’s one value per line and it’s 5 million lines, or it’s 5 million numbers on a line?
– Elton Nunes
There are 9 or 10 columns with 5 million lines. I believe the program is reading all the numbers
– Isabella Rosa