I am a beginner python user. Having trouble getting data from csv into python in the required object format to satisfy a python function. If I manually created the data in python (rather than bringing it in from csv) the following code works:
class Student(object):
pass
john = Student()
#score tuple
john.score = (85.0, 42.0/2.0)
bob = Student()
bob.score = (45.0, 19.0/2.0)
john.rank = 1
bob.rank = 2
ExternalCode.AdjustStudents([john, bob])
However I need it to work automatically and not have to manually type out the data each time as there are going to be thousands of updates - hence the need to be able to bring in the data from csv.
The csv file format is: john, 85, 21, 1 bob, 45, 9.5, 2
Student objects would have a score attribute (columns 2 and 3 as a tuple) as well as a rank attribute (column 4). The required object format would be the same as produced by the manual code above.
An example of the required format produced by the manual code, is that when I do the following print after the manual code:
print(" John: score1={0[0]:.3f} score2={0[1]:.3f}".format(john.skill))
I get this result:
John: score1=25.000 score2=8.333
Cheers,
Steve