I need help with this query/question...
How can i collect data from specific column in file, like this:
**[FILE.txt]**
CODE \t USERNAME \t SPENT \t COLUM1 \t COLUM2
CODE \t USERNAME \t SPENT \t COLUM1 \t COLUM2
CODE \t USERNAME \t SPENT \t COLUM1 \t COLUM2
CODE \t USERNAME \t SPENT \t COLUM1 \t COLUM2
CODE \t USERNAME \t SPENT \t COLUM1 \t COLUM2
CODE \t USERNAME \t SPENT \t COLUM1 \t COLUM2
CODE \t USERNAME \t SPENT \t COLUM1 \t COLUM2
Remember...This is examples of users in this files... Every user can have diferent values on SPENT...
I'll put the values of user1,user2,user3 in a accumulator.
So...how can i proceed?
SOLVED WITH
lines = open("database").readlines()
quantidade = 0
for i in range(3):
line = lines[i].split('\t')
quantidade = quantidade + int(line[2])
print "Quantidade de Produtos Comprados: ",quantidade
#for line in range (10):
# line = lines[-2].split() #Gets the second last value from the list and split on whitespace
# print line
raw_input("Precione 'ENTER' para voltar ao menu principal... ")
return