title: How to work with csv files in Python?
body: <p>What is the 'Python way' regarding working with a CSV file?  If I want to run some methods on the data in a particular column, should copy the whole think into an array, or should I pass the open file into a series of methods?</p>
  
  <p>I tried to return the open file and got this error:  </p>
  
  <pre><code>ValueError: I/O operation on closed file
  </code></pre>
  
  <p>here's the code:</p>
  
  <pre><code>import sys
  import os
  import csv
  
  def main():
  pass
  
  
  def openCSVFile(CSVFile, openMode):
  with open(CSVFile, openMode) as csvfile:
      zipreader = csv.reader(csvfile, delimiter=',')
  return zipreader
  
  if __name__ == '__main__':
  
      zipfile = openCSVFile('propertyOutput.csv','rb')
      numRows = sum(1 for row in zipfile)
      print"Rows equals %d." % numRows
  </code></pre>