def print_column_names(self): """ Pretty-prints the names and indices of all columns to a file-like object (usually sys.stdout). """ if getattr(self.args, 'no_header_row', None): raise RequiredHeaderError('You cannot use --no-header-row with the -n or --names options.') if getattr(self.args, 'zero_based', None): start = 0 else: start = 1 rows = agate.csv.reader(self.skip_lines(), **self.reader_kwargs) column_names = next(rows) for i, c in enumerate(column_names, start): self.output_file.write('%3i: %s\n' % (i, c))
def print_column_names(self): """ Pretty-prints the names and indices of all columns to a file-like object (usually sys.stdout). """ if self.args.no_header_row: raise RequiredHeaderError('You cannot use --no-header-row with the -n or --names options.') f = self.input_file output = self.output_file try: zero_based=self.args.zero_based except: zero_based=False rows = CSVKitReader(f, **self.reader_kwargs) column_names = next(rows) for i, c in enumerate(column_names): if not zero_based: i += 1 output.write('%3i: %s\n' % (i, c))