import csv csv_file = csv.reader(open("your_file_name.csv")) dist = 0 for row in csv_file: _dist = row[2] try: _dist = float(_dist) except ValueError: _dist = 0 dist += _dist