title: Perform a calculation in a newly added column in csv in python
body: <p>I am trying to add a new column to a csv file in python 3. The csv file has a header row, and the first two columns i don't need at this point. the other 8 columns contain 4 coordinates of a polygon. I am trying to add a new column that calculates the area from the points in the csv. I have seen several questions similar on stack overflow, and have tried to use the information there in my code however at the moment, only the last line of the csv is displaying and the I don't think the area is calculating correctly either. Any suggestions? (FYI this is my first code with a csv.)
  Here is my code:</p>
  
  <pre><code>with open(poly.csv, 'rU')as input:
      with open ('polyout.csv', 'w') as output:
          writer = csv.writer(output, lineterminator='\n')
          reader=csv.reader(input)
  
          coords=[]
          row =next(reader)
          row =next(reader,None)
          coords=row[2:]
  
          prev_de=coords[-2]
          prev_dn=coords[-1]
          prev_de=float(prev_de)
          prev_dn=float(prev_dn)
          areasq=float(0)
  
          for de,dn in zip(coords[:-1:2], coords[1::2]):
              areasq+= (float(de)*float(prev_dn))-(float(dn)*float(prev_de))
              prev_de, prev_dn = de,dn
              area =abs(areasq)/2
  
          for row in reader:
              row.append(area)  
              coords.append(row)
  
          writer.writerows(coords)
  
          print(row)
  </code></pre>