GXTB class¶
- class GXTB(handle=0)[source]¶
GXTB class.
The
GXTB
class is a high-performance table class used to perform table-based processing, such as leveling data in an OASIS database. TheGXLTB
class is recommended for use with small tables produced from short lists such as the different geographic projections and their defining parameters.- classmethod create(name)[source]¶
Loads a table into memory and return a table handle.
New in version 5.0.
License: Geosoft Open License
Note: If the table contains fewer data columns than are defined by the the table header, the
GXTB
object will read in the table and dummy the elements of the missing data columns.
- classmethod create_db(db)[source]¶
Create a table from a database.
New in version 5.0.
License: Geosoft Open License
Note: The table will contain fields for all channels in the database.
The database is not loaded with data. Use the
load_db
function to load data into the table.
- classmethod create_ltb(ltb)[source]¶
Create a table from an
GXLTB
database.New in version 5.0.
License: Geosoft Open License
- data_type(col)[source]¶
Returns the data type for the specified column.
- Parameters:
col (int) – Column of element to Get
- Returns:
- Return type:
int
New in version 5.0.1.
License: Geosoft Open License
- field(name)[source]¶
Get a field handle.
- Parameters:
name (str) – Field name
- Returns:
The handle to the field (must be present)
- Return type:
int
New in version 5.0.
License: Geosoft Open License
- find_col_by_index(idx, name)[source]¶
Finds a column’s name by its index.
- Parameters:
idx (int) – Index of column to find
name (str_ref) – Buffer for column name
New in version 5.1.6.
License: Geosoft Open License
- find_col_by_name(name)[source]¶
Finds a column’s index by its name.
- Parameters:
name (str) – Name of column to find
- Returns:
Index of column. -1 if not found.
- Return type:
int
New in version 5.0.
License: Geosoft Open License
- format(col)[source]¶
Returns the channel format for the specified column.
- Parameters:
col (int) – Column of element to Get
- Returns:
- Return type:
int
New in version 5.0.1.
License: Geosoft Open License
- get_double(row, col)[source]¶
Gets an real value from a table element.
- Parameters:
row (int) – Row of element to Get
col (int) – Column of element to Get
- Returns:
Value
- Return type:
float
New in version 5.0.
License: Geosoft Open License
- get_int(row, col)[source]¶
Gets an integer value from a table element.
- Parameters:
row (int) – Row of element to Get
col (int) – Column of element to Get
- Returns:
Value
- Return type:
int
New in version 5.0.
License: Geosoft Open License
- get_string(row, col, val)[source]¶
Gets a string value from a table element.
- Parameters:
row (int) – Row of element to Get
col (int) – Column of element to Get
val (str_ref) – Returned string
New in version 5.0.
License: Geosoft Open License
- is_null()[source]¶
Check if this is a null (undefined) instance
- Returns:
True if this is a null (undefined) instance, False otherwise.
- Return type:
bool
- load_db(db, line)[source]¶
Load a database into a
GXTB
- Parameters:
db (GXDB) – Database
line (int) – Line
New in version 5.0.
License: Geosoft Open License
Note: The line is appended to the data already in the table.
- num_columns()[source]¶
Gets the number of data fields (columns) in a table.
- Returns:
Number of columns
- Return type:
int
New in version 5.0.
License: Geosoft Open License
- num_rows()[source]¶
Gets the number of data rows in a table.
- Returns:
Number of rows
- Return type:
int
New in version 5.0.
License: Geosoft Open License
- save(name)[source]¶
Saves the data in a table to a file. The table header will be in ASCII and the data will be in BINARY format.
- Parameters:
name (str) – Name of File to save table into
New in version 5.0.
License: Geosoft Open License
- save_db(db, line)[source]¶
Save a
GXTB
in a database line- Parameters:
db (GXDB) – Database
line (int) – Line
New in version 5.0.
License: Geosoft Open License
Note: Missing channels are created. Data in existing channels on the line will be replaced.
- save_to_ascii(name)[source]¶
Saves the data in a table to a file. The table header will be in ASCII and the data will be in ASCII format.
- Parameters:
name (str) – Name of File to save table into
New in version 5.0.
License: Geosoft Open License
- set_double(row, col, val)[source]¶
Sets an real value into a table element.
- Parameters:
row (int) – Row of element to set
col (int) – Column of element to set
val (float) – Value to set
New in version 5.0.
License: Geosoft Open License
Note: The table field containing the element to be set MUST be of type
GS_FLOAT
orGS_DOUBLE
. If the field isGS_FLOAT
the new data value will cause an overflow if the value is out of range of the data type. The new element value will then be invalid.If the row of the new element exceeds the number of rows in the table, then the table will AUTOMATICALLY be EXPANDED to exactly as many rows needed to hold the new element. The new element is placed in the proper field of the last row, and all other field elements have invalid data. All fields of the new rows up to the new element’s row will also contain invalid data.
- set_int(row, col, val)[source]¶
Sets an integer value into a table element.
- Parameters:
row (int) – Row of element to set
col (int) – Column of element to set
val (int) – Value to set
New in version 5.0.
License: Geosoft Open License
Note: The table field containing the element to be set MUST be of type
GS_BYTE
,GS_USHORT
,GS_SHORT
, orGS_LONG
. If the field isGS_BYTE
,GS_USHORT
, orGS_LONG
, the new data value will cause an overflow if the value is out of range of the data type. The new element value will then be invalid.If the row of the new element exceeds the number of rows in the table, then the table will AUTOMATICALLY be EXPANDED to exactly as many rows needed to hold the new element. The new element is placed in the proper field of the last row, and all other field elements have invalid data. All fields of the new rows up to the new element’s row will also contain invalid data.
- set_search_mode(mode)[source]¶
Set the search mode of a table.
- Parameters:
mode (int) – TB_SEARCH constants
New in version 5.0.
License: Geosoft Open License
Note: If performance is an issue, you may want to test which search mode provides the best performance with typical data.
- set_sort_mode(mode)[source]¶
Set the sort mode of a table.
- Parameters:
mode (int) – TB_SORT constants
New in version 9.3.1.
License: Geosoft Open License
- set_string(row, col, val)[source]¶
Sets a string value into a table element.
- Parameters:
row (int) – Row of element to set
col (int) – Column of element to set
val (str) – Value to set
New in version 5.0.
License: Geosoft Open License
Note: The table field containing the element to be set MUST be of ‘string’.
If the row of the new element exceeds the number of rows in the table, then the table will AUTOMATICALLY be EXPANDED to exactly as many rows needed to hold the new element. The new element is placed in the proper field of the last row, and all other field elements have invalid data. All fields of the new rows up to the new element’s row will also contain invalid data.
- sort(col)[source]¶
Sorts a table by a specified column.
- Parameters:
col (int) – Index of data Column to sort table by
New in version 5.0.
License: Geosoft Open License
Note: If the column to sort by contains duplicated values, the sorted table is NOT guaranteed to retain the ordering of the duplicated values/ E.g. Given 2 rows of values: xx yy 1 bb aa 1 If the table is sorted on column 3, the second row may or may not come after the first row in the sorted table.
TB_SEARCH constants¶
GXTB
Searching mode
TB_SORT constants¶
GXTB
Sorting mode