Skip to main content
`Ctrl`+`K`

# read

astropy.io.ascii.read(table, guess=None, **kwargs)

  Read the input `table` and return the table. Most of the default behavior for various parameters is determined by the `format` argument.

  Help on the `read()` function arguments is available as shown in this example:

      from astropy.io import ascii
      ascii.read.help()  # Common help for all formats
      ascii.read.help("html")  # Common help plus "html" format-specific args

  See also:

  - https://docs.astropy.org/en/stable/io/ascii/

  - https://docs.astropy.org/en/stable/io/ascii/read.html

  Parameters:
    table `python:str`, python:file-like object, `python:list`, `pathlib.Path` `object`

      Input table as a file name, file-like object, list of string[s], single newline-separated string or `pathlib.Path` object.

    guess bool

      Try to guess the table format. Defaults to None.

    format `python:str`, `BaseReader`

      Input table format

    delimiter `python:str`

      Column delimiter string

    comment `python:str`

      Regular expression defining a comment line in table

    quotechar `python:str`

      One-character string to quote fields containing special characters

    header_start `python:int`

      Line index for the header line not counting comment or blank lines. A line with only whitespace is considered blank.

    data_start `python:int`

      Line index for the start of data not counting comment or blank lines. A line with only whitespace is considered blank.

    data_end `python:int`

      Line index for the end of data not counting comment or blank lines. This value can be negative to count from the end.

    converters `python:dict`

      Dictionary of converters to specify output column dtypes. Each key in the dictionary is a column name or else a name matching pattern including wildcards. The value is either a data type such as `int` or `np.float32`; a list of such types which is tried in order until a successful conversion is achieved; or a list of converter tuples (see the `convert_numpy` function for details).

    names `python:list`

      List of names corresponding to each data column

    include_names `python:list`

      List of names to include in output.

    exclude_names `python:list`

      List of names to exclude from output (applied after `include_names`)

    fill_values `python:tuple`, `python:list` of `python:tuple`

      specification of fill values for bad or missing table values

    fill_include_names `python:list`

      List of names to include in fill_values.

    fill_exclude_names `python:list`

      List of names to exclude from fill_values (applied after `fill_include_names`)

    fast_reader bool, `python:str` or `python:dict`

      Whether to use the C engine, can also be a dict with options which defaults to `False`; parameters for options dict:

      use_fast_converter: bool

        enable faster but slightly imprecise floating point conversion method

      exponent_style: str

        One-character string defining the exponent or `'Fortran'` to auto-detect Fortran-style scientific notation like `'3.14159D+00'` (`'E'`, `'D'`, `'Q'`), all case-insensitive; default `'E'`, all other imply `use_fast_converter`

      chunk_sizeint

        If supplied with a value > 0 then read the table in chunks of approximately `chunk_size` bytes. Default is reading table in one pass.

      chunk_generatorbool

        If True and `chunk_size > 0` then return an iterator that returns a table for each chunk. The default is to return a single stacked table for all the chunks.

    encoding `python:str`

      Allow to specify encoding to read the file (default= `None`).

  Returns:
    dat `Table` or <generator>

      Output table

  Other Parameters:
    inputter_cls `BaseInputter`

      Inputter class

    outputter_cls `BaseOutputter`

      Outputter class

    data_splitter_cls `BaseSplitter`

      Splitter class to split data columns

    header_splitter_cls `BaseSplitter`

      Splitter class to split header columns