MCPcopy Create free account
hub / github.com/wireservice/csvkit / print_column_names

Method print_column_names

csvkit/cli.py:435–451  ·  view source on GitHub ↗

Pretty-prints the names and indices of all columns to a file-like object (usually sys.stdout).

(self)

Source from the content-addressed store, hash-verified

433 return rows, column_names, column_ids
434
435 def print_column_names(self):
436 """
437 Pretty-prints the names and indices of all columns to a file-like object (usually sys.stdout).
438 """
439 if getattr(self.args, 'no_header_row', None):
440 raise RequiredHeaderError('You cannot use --no-header-row with the -n or --names options.')
441
442 if getattr(self.args, 'zero_based', None):
443 start = 0
444 else:
445 start = 1
446
447 rows = agate.csv.reader(self.skip_lines(), **self.reader_kwargs)
448 column_names = next(rows)
449
450 for i, c in enumerate(column_names, start):
451 self.output_file.write('%3i: %s\n' % (i, c))
452
453 def additional_input_expected(self):
454 return isatty(sys.stdin) and not self.args.input_path

Callers 4

mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80
mainMethod · 0.80

Calls 2

skip_linesMethod · 0.95
RequiredHeaderErrorClass · 0.90

Tested by

no test coverage detected