ECSVEngine#
- class astropy.io.misc.ecsv.ECSVEngine[source]#
Bases:
objectBase 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.
nameandformatmust be defined as class attributes in subclasses.enginesis 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 anInt32Dtype()instance to read columns as a nullable int32.- Parameters:
- np_type
python:str The numpy type string to be converted.
- np_type
- Returns:
AnyCorresponding 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:
- header
ECSVHeader The ECSV header containing column definitions.
- header
- 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:
- header
ECSVHeader ECSVHeader object within header information.
- null_values
python:listofpython:str List of strings with values to be interpreted as null or missing data.
- header
- Returns:
python:dict[python:str,Any]Dict of keyword arguments to be passed to engine CSV reader.