Skip to main content
`Ctrl`+`K`

# ECSVEngine

class astropy.io.misc.ecsv.ECSVEngine

  Bases: `object`

  Base class for ECSV reader engines.

  An engine is responsible for reading the raw CSV data that follows the ECSV header. This assumes that the engine has a defined Table Unified I/O interface.

  - `name` and `format` must be defined as class attributes in subclasses.

  - `engines` is a base class-level dictionary that maps engine names to their respective engine classes. Subclasses should not modify this directly.

  Parameters:
    name `python:str`

      Name of the engine, used for `engine` parameter in a call like: `Table.read(filename, format="ecsv", engine="pyarrow")`.

    format `python:str`

      Format string for the engine CSV reader, e.g. “pyarrow.csv”, “ascii.csv”, etc.

    engines `python:dict`[`python:str`, `ECSVEngine`]

      Dictionary mapping engine names to their respective engine classes.

  Attributes Summary

  `engines` |
  `format` |
  `name` |

  Methods Summary

  `convert_np_type`(np_type) | Convert a numpy type string to engine-specific type for parsing.
  `get_converters`(header) | Get a dictionary of converters for the columns in the ECSV header.
  `get_data_kwargs`(header, null_values) | Generate a dictionary of keyword arguments for data parsing.

  Attributes Documentation

  engines = {'io.ascii': <class 'astropy.io.misc.ecsv.ECSVEngineIoAscii'>, 'pandas': <class 'astropy.io.misc.ecsv.ECSVEnginePandas'>, 'pyarrow': <class 'astropy.io.misc.ecsv.ECSVEnginePyArrow'>}
  format = None
  name = None

  Methods Documentation

  abstractmethod convert_np_type(np_type)

    Convert a numpy type string to engine-specific type for parsing.

    For instance, for pandas the `"int32"` numpy type gets converted to an `Int32Dtype()` instance to read columns as a nullable int32.

    Parameters:
      np_type `python:str`

        The numpy type string to be converted.

    Returns:
      `Any`

        Corresponding engine-specific type.

  get_converters(header)

    Get a dictionary of converters for the columns in the ECSV header.

    This is used to convert column names to engine-specific types.

    Parameters:
      header `ECSVHeader`

        The ECSV header containing column definitions.

    Returns:
      `python:dict`[`python:str`, `Any`]

        Dictionary mapping column names to engine-specific converters.

  abstractmethod get_data_kwargs(header, null_values)

    Generate a dictionary of keyword arguments for data parsing.

    This accounts for the API variations in each engine CSV reader.

    Parameters:
      header `ECSVHeader`

        ECSVHeader object within header information.

      null_values `python:list` of `python:str`

        List of strings with values to be interpreted as null or missing data.

    Returns:
      `python:dict`[`python:str`, `Any`]

        Dict of keyword arguments to be passed to engine CSV reader.