getTable(table,
filter,
sortcol=None,
exactly_one=False,
at_least_one=False)
| source code
|
Return row(s) of a table that match the filter.
Rows that match every item in the filter (a dictionary of
column_name=value) will be returned. If the value in the table is
STRING_WILDCARD or INT_WILDCARD (depending on the data type of the
column), that value is considered to match the filter for that column.
Also, for a given filter key, if the corresponding value in the filter is
STRING_WILDCARD, the test on filter will be skipped for that key (i.e. a
wildcard filter element matches any row).
If more than one row matches the filter, there is an option to sort
these rows based on the values of one of the table columns.
It is an error if exactly_one or at_least_one is True but no row
matches the filter. A warning will be printed if exactly_one is True but
more than one row matches the filter.
- Parameters:
table (string) - name of the reference table
filter (dictionary) - each key is a column name, and the corresponding value is a
possible table value in that column
sortcol (string) - the name of a column on which to sort the table rows (if there is
more than one matching row), or None to disable sorting
exactly_one (boolean) - set this to True if there must be one and only one matching row
at_least_one (boolean) - set this to True if there must be at least one matching row
- Returns: record array (a pyfits table data object)
- an array of the rows of the table that match the filter; note
that if only one row matches the filter, the function value will
still be an array
|