The code I have so far is in a function that basically reads a csv file and prints it's contents:
def read(filename):
with open(filename, 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
print(row)
Contents of sailor.csv
:
name, mean performance , std dev
Alice, 100, 0,
Bob, 100, 5,
Clare, 100, 10,
Dennis, 90, 0,
Eva, 90, 5,
read('sailor.csv')
and running the function
current output:
['name', ' mean performance ', ' std dev']
['Alice', ' 100', ' 0', '']
['Bob', ' 100', ' 5', '']
['Clare', ' 100', ' 10', '']
['Dennis', ' 90', ' 0', '']
['Eva', ' 90', ' 5', '']
required output:
{'Dennis': (90.0, 0.0), 'Clare':(100.0, 10.0),
'Eva': (90.0, 5.0), 'Bob': (100.0, 5.0), 'Alice': (100.0, 0.0)}
any ideas how I can achieve that output? Using Python 3.4.2 if that helps, explanation of your answer will be appreciated!