GXTB class

class GXTB(handle=0)

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. The GXLTB 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)

Loads a table into memory and return a table handle.

Parameters:name (str) – Name of the table file to load
Returns:GXTB Object
Return type:GXTB

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)

Create a table from a database.

Parameters:db (GXDB) – Database
Returns:GXTB Object
Return type:GXTB

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)

Create a table from an GXLTB database.

Parameters:ltb (GXLTB) – GXLTB object
Returns:GXTB Object
Return type:GXTB

New in version 5.0.

License: Geosoft Open License

data_type(col)

Returns the data type for the specified column.

Parameters:col (int) – Column of element to Get
Returns:DB_CATEGORY_CHAN constants
Return type:int

New in version 5.0.1.

License: Geosoft Open License

field(name)

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)

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)

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)

Returns the channel format for the specified column.

Parameters:col (int) – Column of element to Get
Returns:DB_CHAN_FORMAT constants
Return type:int

New in version 5.0.1.

License: Geosoft Open License

get_double(row, col)

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)

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)

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()

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)

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.

classmethod null()

A null (undefined) instance of GXTB

Returns:A null GXTB
Return type:GXTB
num_columns()

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()

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)

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)

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)

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)

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 or GS_DOUBLE. If the field is GS_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)

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, or GS_LONG. If the field is GS_BYTE, GS_USHORT, or GS_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)

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_string(row, col, val)

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)

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_SEARCH_BINARY

Random searches in a table.

gxapi.TB_SEARCH_BINARY = 0
TB_SEARCH_LINEAR

Linear searches up or down a table (Default).

gxapi.TB_SEARCH_LINEAR = 1