ECSVEngine#

class astropy.io.misc.ecsv.ECSVEngine[source]#

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.

Attributes Summary

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)[source]#

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_typepython:str

The numpy type string to be converted.

Returns:
Any

Corresponding engine-specific type.

get_converters(header)[source]#

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

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

Parameters:
headerECSVHeader

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)[source]#

Generate a dictionary of keyword arguments for data parsing.

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

Parameters:
headerECSVHeader

ECSVHeader object within header information.

null_valuespython: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.