parse¶
-
astropy.io.votable.
parse
(source, columns=None, invalid='exception', pedantic=None, chunk_size=256, table_number=None, table_id=None, filename=None, unit_format=None, datatype_mapping=None, _debug_python_based_parser=False)[source] [edit on github]¶ Parses a VOTABLE xml file (or file-like object), and returns a
VOTableFile
object.Parameters: - source : str or readable file-like object
Path or file object containing a VOTABLE xml file.
- columns : sequence of str, optional
List of field names to include in the output. The default is to include all fields.
- invalid : str, optional
One of the following values:
- ‘exception’: throw an exception when an invalid value is encountered (default)
- ‘mask’: mask out invalid values
- pedantic : bool, optional
When
True
, raise an error when the file violates the spec, otherwise issue a warning. Warnings may be controlled using the standard Python mechanisms. See thewarnings
module in the Python standard library for more information. When not provided, uses the configuration settingastropy.io.votable.pedantic
, which defaults to False.- chunk_size : int, 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_number : int, 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 withtable_id
.- table_id : str, optional
The ID of the table in the file to read in. Should not be used with
table_number
.- filename : str, 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_format : str, 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
, andvounit
. A custom formatter may be provided by passing aUnitBase
instance. IfNone
(default), the unit format to use will be the one specified by the VOTable specification (which iscds
up to version 1.2 of VOTable, and (probably)vounit
in future versions of the spec).- datatype_mapping : dict of str to str, optional
A mapping of datatype names to valid VOTable datatype names. For example, if the file being read contains the datatype “unsignedInt” (an invalid datatype in VOTable), include the mapping
{"unsignedInt": "long"}
.
Returns: - votable :
VOTableFile
object
See also
astropy.io.votable.exceptions
- The exceptions this function may raise.