Country Gold Silver Bronze Total
US 9 15 13 37
GE 10 13 7 30
CA 14 7 5 26
NO 9 8 6 23
AU 4 6 6 16
RF 3 5 7 15
KO 6 6 2 14
CH 5 2 4 11
SW 5 2 4 11
FR 2 3 6 11
I have to take a file which will be formatted exactly like this (medal_count.txt) and take all the numerical values and plot a bar graph, using Quick Draw, which is completely useless, but I would greatly appreciate it if someone could help explain to me how to find the max and the min of a file like this (I can not use this EXACT example, as I will have use a different file with this format). I have been trying to put it into a string which I can later read using for loops but they are always seperate and it never seems to work. Any help would be great. All I am asking is how I could take a file like this, find the maximum and the minimum and using functions later on drawing the graph. Please note, I do also need to be able to find negative values as well!
import sys
file = sys.argv[1]
file = open(file, 'r')
lines = 0
bars = 0
for line in file:
line += 1
words = line.split(None)
bars += len(words)
print lines
print bars
I have done this to determine the x_variables and bar lines required. But I do not know a max or a min. Please, any help will be awesome. Thanks.