Skip to main content
`Ctrl`+`K`

# BaseHeader

class astropy.io.ascii.BaseHeader

  Bases: `object`

  Base table header reader.

  Attributes Summary

  `auto_format` | format string for auto-generating column names
  `colnames` | Return the column names of the table.
  `comment` | regular expression for comment lines
  `names` | list of names corresponding to each data column
  `start_line` | None, int, or a function of `lines` that returns None or int
  `write_comment` |
  `write_spacer_lines` |

  Methods Summary

  `check_column_names`(names, strict_names, guessing) | Check column names.
  `get_col_type`(col) |
  `get_cols`(lines) | Initialize the header Column objects from the table `lines`.
  `get_type_map_key`(col) |
  `process_lines`(lines) | Generator to yield non-blank and non-comment lines.
  `remove_columns`(names) | Remove several columns from the table.
  `rename_column`(name, new_name) | Rename a column.
  `update_meta`(lines, meta) | Extract any table-level metadata, e.g. keywords, comments, column metadata, from the table `lines` and update the OrderedDict `meta` in place.
  `write`(lines) |
  `write_comments`(lines, meta) |

  Attributes Documentation

  auto_format = 'col{}'

    format string for auto-generating column names

  colnames

    Return the column names of the table.

  comment = None

    regular expression for comment lines

  names = None

    list of names corresponding to each data column

  start_line = None

    None, int, or a function of `lines` that returns None or int

  write_comment = False
  write_spacer_lines = ['ASCII_TABLE_WRITE_SPACER_LINE']

  Methods Documentation

  check_column_names(names, strict_names, guessing)

    Check column names.

    This must be done before applying the names transformation so that guessing will fail appropriately if `names` is supplied. For instance if the basic reader is given a table with no column header row.

    Parameters:
      names `python:list`

        User-supplied list of column names

      strict_names bool

        Whether to impose extra requirements on names

      guessing bool

        True if this method is being called while guessing the table format

  get_col_type(col)
  get_cols(lines)

    Initialize the header Column objects from the table `lines`.

    Based on the previously set Header attributes find or create the column names. Sets `self.cols` with the list of Columns.

    Parameters:
      lines `python:list`

        List of table lines

  get_type_map_key(col)
  process_lines(lines)

    Generator to yield non-blank and non-comment lines.

  remove_columns(names)

    Remove several columns from the table.

    Parameters:
      names `python:list`

        A list containing the names of the columns to remove

  rename_column(name, new_name)

    Rename a column.

    Parameters:
      name `python:str`

        The current name of the column.

      new_name `python:str`

        The new name for the column

  update_meta(lines, meta)

    Extract any table-level metadata, e.g. keywords, comments, column metadata, from the table `lines` and update the OrderedDict `meta` in place. This base method extracts comment lines and stores them in `meta` for output.

  write(lines)
  write_comments(lines, meta)