code: def csv_writer(csvfile):
          
          if sys.version_info >= (3,):
              writer = csv.writer(csvfile, delimiter=',', lineterminator='\n')
          else:
              writer = csv.writer(csvfile, delimiter=b',', lineterminator='\n')
  
          return writer
docs: Get a CSV writer for the version of python that is being run.