code: def save_csv(p, sheet):
      'Save as single CSV file, handling column names as first line.'
      with p.open_text(mode='w') as fp:
          cw = csv.writer(fp, **csvoptions())
          colnames = [col.name for col in sheet.visibleCols]
          if ''.join(colnames):
              cw.writerow(colnames)
          for r in Progress(sheet.rows, 'saving'):
              cw.writerow([col.getDisplayValue(r) for col in sheet.visibleCols]f save_csv(p, sheet):
      'Save as single CSV file, handling column names as first line.'
      with p.open_text(mode='w') as fp:
          cw = csv.writer(fp, **csvoptions())
          colnames = [col.name for col in sheet.visibleCols]
          if ''.join(colnames):
              cw.writerow(colnames)
          for r in Progress(sheet.rows, 'saving'):
              cw.writerow([col.getDisplayValue(r) for col in sheet.visibleCols])
docs: Save as single CSV file, handling column names as first line.