title: Comparing two rows from a csv file in Python
body: <p>I am trying to write a manhattan_distance function which would compare two rows from a csv file. I already have a function which reads all the rows from a file but I am unable to access 'row' from this function to use for comparison in the second function. The error I get is "name 'row' not defined". 
  Here is my code:</p>
  
  <pre><code>def load_from_csv(filename):    
      with open(filename,'r') as csvfile: 
          reader = csv.reader(csvfile, delimiter=',', quotechar='|') 
          for row in reader:
              print(row)
          return row 
  
  load_from_csv('data.csv') 
  
  def manhattan_distance(x,y):
   return sum(abs(a-b) for a,b in zip(x,y))
  
  print (manhattan_distance(row[1],row[2]))
  </code></pre>
  
  <p>a sample from the csv file (first two rows):</p>
  
  <p>14.23   1.71    2.43    15.6    127 2.8 3.06    0.28    2.29    5.64    1.04    3.92    1065</p>
  
  <p>13.2    1.78    2.14    11.2    100 2.65    2.76    0.26    1.28    4.38    1.05    3.4 1050</p>
  
  <p>Sorry if this is a silly question but I'm not good with Python and I am struggling to find a relevant answer online.</p>