I need to sort some information from an array. I'm trying to find the minimum value out of two numbers, from a csv file, the first part of the information in the file is the names of people, so instead of 0, I put 1 in int(row[1])

import csv
print("1 for Group A\n2 for Group B\n3 for     Group C")
choice = (input)
Group_A = open("class scores A.csv")
Group_B = open("class scores B.csv")
Group_C = open("class scores C.csv")
if choice == 1:
    print("1 for students' highest score in   alphabetical order\n2 for highest score to lowest score\n3 for average score highest to lowest")
choiceTwo = int(input())
csv_a = csv.reader(Group_A)
newlist_ = []
for row in csv_a:
    row[1] = int(row[1])
    row[2] = int(row[2])
    minimum = min(row[1:2])

But then python tells me that the index is out of range, and if I put 0 instead of 1, it tells me that there's an invalid literal, and I know that's because, there's text in the first part. What should I do?

Are there three columns in total, a name and then two numbers e.g. bruce, 1, 5?
You haven't stated where the error is actually occuring but is it at line 14: int( row[2] )?

If there aren't 3 columns then that should be the problem, column 2 (the third) doesn't exist.

The error is occurring in line 13, according to Python, but I have two columns so I'll try to add another and see if it works

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.