I have a text file named hsp.txt
in C:\Python27\Lib\site-packages\visual\examples
and used the following code.
def file():
file = open('hsp.txt', 'r')
col = []
data = file.readlines()
for i in range(1,len(data)-1):
col.append(int(float(data[i].split(',')[5])))
return col
def hist(col):
handspan = []
for i in range(11):
handspan.append(0)
for i in (col):
handspan[i] += 1
return handspan
col = file()
handspan = hist(col)
print(col)
print(handspan)
But when I run it it says that that the file doesn't exist.
Traceback (most recent call last):
File "Untitled", line 17
col = file()
File "Untitled", line 2, in file
file = open('hsp.txt', 'r')
IOError: [Errno 2] No such file or directory: 'hsp.txt'
How do I fix this? Also how do I output the mean and variance?