register_identifier

astropy.table.io_registry.register_identifier(table_format, identifier, force=False) [edit on github][source]

Associate an identifier function with a specific table type.

Parameters :

table_format : str

The table type identifier. This is the string that is used to specify the table type when reading/writing.

identifier : function

A function that checks the argument specified to Table.read or Table.write to determine whether the input can be interpreted as a table of type table_format. This function should take two arguments, which will be set to the list of arguments and a dictionary of keyword arguments passed to Table.read or Table.write. The function should return True if the input can be identified as being of format table_format, and False otherwise.

force : bool

Whether to override any existing function if already present.

Examples

To set the identifier based on extensions, for formats that take a filename as a first argument, you can do for example:

>>> register_identifier('ipac', lambda args, kwargs: isinstance(args[0], basestring) and args[0].endswith('.tbl'))

Page Contents