0

I am importing a data file where the years are two digit integers. So 1982 is 82. Using csv reader, I would like to prepend the integer 19 to the years. Here is the for loop I am using. It works great. I just want to prepend 19. ('19'+int(record.year) gives me a string error. Here is my code.

with open('auto.clean.txt') as f:
            reader = csv.reader(f, delimiter= ' ', skipinitialspace=True)
            for row in reader:
                record = Record(row[0], row[1], row[2],row[3],row[4],row[5],row[6],row[7],row[8])
                tokens = record.car_name.split(' ')
                make = tokens[0]
                model = ' '.join(tokens[1:])              
                r = AutoMPG(make, model, (int(record.year)), float(record.mpg))
                self.data.append(r)
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

0 Answers0