title: How to count number of columns in csv python?
body: <pre><code>dic = {}
  counter = 0 
  
  years = ['2000','2001','2002','2003','2004','2005','2006','2007','2008',
          '2009','2010','2011','2012','2013','2014','2015','2016', '2017']
  
  for y in years:
      dic[y] = 0
  
  with open(file_path) as csvf:
      reader = csv.reader(csvf)
      next(reader)
  
      for row in reader:
  
          dic[row[0]] += int(row[1])
          print(dic)
  
  years, average_grades = [], []
  # YOUR CODE HERE
  return years, average_grades
  </code></pre>
  
  <p>What I am trying to do here is, I am trying to read through a csv file which contains a row with a year and numbers (could be 0 or more than 0).</p>
  
  <p>I eventually have to store</p>
  
  <p>[year] and [average value corresponding to the year]</p>
  
  <p>I am trying to add all values in the value of the key(year) and divide at the end by the number of cols it has. </p>
  
  <p>But I am kind of stuck how to get the number of cols in that row.</p>
  
  <p>Help please.</p>