parse

astropy.io.votable.parse(source, columns=None, invalid='exception', verify=None, chunk_size=256, table_number=None, table_id=None, filename=None, unit_format=None, datatype_mapping=None, _debug_python_based_parser=False)[source]

Parses a VOTABLE xml file (or file-like object), and returns a VOTableFile object.

Parameters
sourcepath-like object or file-like object

Path or file-like object containing a VOTABLE xml file. If file, must be readable.

columnssequence of str, optional

List of field names to include in the output. The default is to include all fields.

invalidstr, optional

One of the following values:

  • ‘exception’: throw an exception when an invalid value is encountered (default)

  • ‘mask’: mask out invalid values

verify{‘ignore’, ‘warn’, ‘exception’}, optional

When 'exception', raise an error when the file violates the spec, otherwise either issue a warning ('warn') or silently continue ('ignore'). Warnings may be controlled using the standard Python mechanisms. See the warnings module in the Python standard library for more information. When not provided, uses the configuration setting astropy.io.votable.verify, which defaults to ‘ignore’.

Changed in version 4.0: verify replaces the pedantic argument, which will be deprecated in future.

Changed in version 5.0: The pedantic argument is deprecated.

chunk_sizeint, optional

The number of rows to read before converting to an array. Higher numbers are likely to be faster, but will consume more memory.

table_numberint, optional

The number of table in the file to read in. If None, all tables will be read. If a number, 0 refers to the first table in the file, and only that numbered table will be parsed and read in. Should not be used with table_id.

table_idstr, optional

The ID of the table in the file to read in. Should not be used with table_number.

filenamestr, optional

A filename, URL or other identifier to use in error messages. If filename is None and source is a string (i.e. a path), then source will be used as a filename for error messages. Therefore, filename is only required when source is a file-like object.

unit_formatstr, astropy.units.format.Base instance or None, optional

The unit format to use when parsing unit attributes. If a string, must be the name of a unit formatter. The built-in formats include generic, fits, cds, and vounit. A custom formatter may be provided by passing a UnitBase instance. If None (default), the unit format to use will be the one specified by the VOTable specification (which is cds up to version 1.3 of VOTable, and vounit in more recent versions of the spec).

datatype_mappingdict, optional

A mapping of datatype names (str) to valid VOTable datatype names (str). For example, if the file being read contains the datatype “unsignedInt” (an invalid datatype in VOTable), include the mapping {"unsignedInt": "long"}.

Returns
votableVOTableFile object

See also

astropy.io.votable.exceptions

The exceptions this function may raise.