File parser

cast.py

Module to cast the data after parsing.

parse_external.py

Module to parse input files containing externally calibrated sampled spectra.

class ExternalParser[source]

Bases: GenericParser

Parser for externally calibrated sampled spectra.

parse_generic.py

Module to parse input files containing spectra.

exception DataMismatchError[source]

Bases: RuntimeError

Error raised when the data in a file is invalid or the file extension does not match the file contents.

class GenericParser[source]

Bases: object

Generic spectra parser.

get_parser(extension)[source]

Choose the parser to use based on the extension.

Parameters

extension (str) – File extension including the dot (e.g.: ‘.csv’).

Returns

Parse method corresponding to the extension.

Return type

method

Raises

InvalidExtensionError – If the extension is not valid.

parse(file_path)[source]

Parse the input file according to its extension.

Parameters

file_path (str) – Path to a file.

Returns

Pandas DataFrame representing the file. str: File extension (‘.csv’, ‘.fits’, or ‘.xml’).

Return type

DataFrame

exception InvalidExtensionError[source]

Bases: ValueError

Error raised when the extension of the input file is not valid. It inherits from ValueError.

parse_internal_continuous.py

Module to parse input files containing internally calibrated continuous spectra.

class InternalContinuousParser[source]

Bases: GenericParser

Parser for internally calibrated continuous spectra.

parse_internal_sampled.py

Module to parse input files containing internally calibrated sampled spectra.

class InternalSampledParser[source]

Bases: GenericParser

Parser for internally calibrated sampled spectra.

utils.py

Module containing auxiliary functions of the parsers.