1

I don't know how to fix the error (ValueError: could not convert string to float: 'High'). Any help would be much appreciated.

high = 0

with open('file.csv', 'r') as csv_file:
    csv_reader = csv.reader(csv_file)

    for line in csv_reader:

            if float(line[2]) > high:
                high = float(line[2])
Joe James
  • 29
  • 1

1 Answers1

0

I'm guessing your CSV has a header row, so the column value in the first row is the string "High", which can't be converted to a number. Just skip the first row in that case by calling next(csv_reader) before your for loop.

Mark Reed
  • 91,912
  • 16
  • 138
  • 175