GXLST class

class GXLST(handle=0)

GXLST class.

The GXLST class is used to create and retrieve lists, and to perform specific actions on lists, including retrieving list items, sorting lists and adding or removing list items.

add_item(name, val)

Adds an item to the end of the list.

Parameters:
  • name (str) – Name of the Item
  • val (str) – Value of the Item

New in version 5.0.

License: Geosoft Open License

add_symb_item(name, symb)

Adds a channel/line/blob name and symbol to a list.

Parameters:
  • name (str) – Name of the channel, line or blob symbol
  • symb (int) – Symbol handle

New in version 6.2.

License: Geosoft Open License

Note: A number of GXDB functions return LSTs with the channel or line name in the “Name” part of a GXLST, and the handle (DB_SYMB) in the value part. This function lets you quickly add a new item without the need of coverting the handle into a string value.

add_unique_item(name, val)

Adds a unique item to the end of the list.

Parameters:
  • name (str) – Name of the Item
  • val (str) – Value of the Item

New in version 5.0.

License: Geosoft Open License

Note: Existing items that match the name are first removed.

append(lst2)

Add the items in one list to another list.

Parameters:lst2 (GXLST) – List to append to the above GXLST.

New in version 6.2.

License: Geosoft Open License

Note: Item names and values are added using “add_unique_item”, so that existing items with the same name are replaced, and if items are duplicated in the appended GXLST, the last one will be the one to remain after the process is complete.

classmethod assay_channel()

Create a GXLST of assay channel mask strings from file.

Returns:GXLST Object
Return type:GXLST

New in version 5.1.6.

License: Geosoft Open License

Note: Searches the local directory, then useretc, then etc to see if the file “assaylist.csv” exists. The file contains strings of those channel names which are to be interpreted as assay channels for geochemical processes. Items can be on the same line, separated by commas, or on separate lines (and combinations of both). If this function is used in combination with the lFindItemMask_LST function, then you can use mask-strings such as “*ppm” The following is a sample file:

*ppm, *(ppm), *PPM, *(PPM), FeCl, MnO2 "Fe %" FeO

If the file is not found, or if no items are parsed, the list is returned with zero size.

See the “assaylist.csv” file in the oasismontajetc directory for more details.

See also

find_item_mask

clear()

Clear a list object.

New in version 5.0.

License: Geosoft Open License

convert_from_csv_string(buff)

Load a GXLST with items from a string.

Parameters:buff (str) – Comma separated items

New in version 5.1.8.

License: Geosoft Open License

Note: Items in the input buffer must be separated with commas. Both the Name and Value in the list are set to the item.

convert_to_csv_string(buff)

Load a string with names from a GXLST.

Parameters:buff (str_ref) – Buffer to add items to

New in version 5.1.8.

License: Geosoft Open License

Note: The list name values are put into a string, items separated by commas.

copy(source)

Copy one GXLST object to another.

Parameters:source (GXLST) – Source List to Copy from

New in version 5.0.

License: Geosoft Open License

classmethod create(width)

creates a user controllable list. The list is empty when created.

Parameters:width (int) – Width of the list to make. This number should be large enough for both the item name and the item value. Must be > 2 and <= 4096.
Returns:Handle to the List Object.
Return type:GXLST

New in version 5.0.

License: Geosoft Open License

classmethod create_s(bf)

Create GXLST from serialized source.

Returns:GXLST object
Return type:GXLST

New in version 5.0.

License: Geosoft Open License

del_item(item)

Removes an item from the list. All items below it are shifted up one.

Parameters:item (int) – Item Number to Delete

New in version 5.0.

License: Geosoft Open License

find_item(type, name)

Searches the list for a specified item.

Parameters:
  • type (int) – LST_ITEM constants data to do the search on
  • name (str) – String to Search For
Returns:

x - Item Number -1 - Not Found

Return type:

int

New in version 5.0.

License: Geosoft Open License

Note: Comparisons are case-tolerant.

find_item_mask(type, name)

Searches the list for a specified item, list contains masks.

Parameters:
Returns:

x - Item Number -1 - Not Found

Return type:

int

New in version 5.1.6.

License: Geosoft Open License

Note: Comparsions are case-intolerant (unlike find_item). This means items in the list such as “*(ppm)” will be found if the input search string is “Ni (ppm)” or “Ni(ppm)”, but not if it is “Ni (PPM)”, so you should include both “*ppm*” and “*PPM*”.

It is NOT the input string that should be the mask, but the GXLST items themselves

This function was designed originally for geochemical processes in order to identify if a given channel name indicates that the channel should be given the “Assay” class.

See also

assay_channel

find_items(type, lst2, vv)

Searches a GXLST for items in a second GXLST, returns indices of those found.

Parameters:

New in version 6.3.

License: Geosoft Open License

Note: This is a much more efficient way of determining if items in one GXLST are found in a second, than by calling find_item repeatedly in a loop. The returned INT GXVV contains the same number of items as the “search items” GXLST, and contains -1 for items where the value is not found, and the index of items that are found. Comparisons are case-tolerant.

get_double(type, item)

Get a real item.

Parameters:
Returns:

Real, rDUMMY if conversion fails or string is empty.

Return type:

float

New in version 5.1.2.

License: Geosoft Open License

get_int(type, item)

Get an integer item.

Parameters:
Returns:

Integer, iDUMMY if conversion fails or string is empty.

Return type:

int

New in version 5.1.2.

License: Geosoft Open License

gt_item(type, item, buff)

This places the specified item into the buffer provided.

Parameters:
  • type (int) – LST_ITEM constants data to retrieve
  • item (int) – Item Number to Get
  • buff (str_ref) – Buffer to Place Item Into

New in version 5.0.

License: Geosoft Open License

Note: If item number is not in the list, the buffer will be “”.

gt_symb_item(item, name, symb)

Returns a channel/line/blob name and symbol from a list.

Parameters:
  • item (int) – Item number to get
  • name (str_ref) – Buffer to Place Symbol name into
  • symb (int_ref) – Symbol handle

New in version 6.3.

License: Geosoft Open License

Note: A number of GXDB functions return LSTs with the channel or line name in the “Name” part of a GXLST, and the handle (DB_SYMB) in the value part. This function lets you quickly retrieve both the name and symbol handle for a given item, which needing to convert between types.

insert_item(item, name, val)

Adds an item at a given location in the list.

Parameters:
  • item (int) – Item index
  • name (str) – Name of the Item
  • val (str) – Value of the Item

New in version 5.1.6.

License: Geosoft Open License

Note: Index must be 0 >= index >= list size. Items above the list index are shifted up one index value.

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_csv(csv, name_field, value_field)

Load a list with data from a CSV file

Parameters:
  • csv (str) – The CSV file
  • name_field (str) – Column label for the item name
  • value_field (str) – Column label for the item value

New in version 5.0.

License: Geosoft Open License

Note: Both the Item and Value fields must be specified. The CSV file must be comma delimited, and have a header line with the field names. Leading and trailing spaces are removed in the names and values.

load_file(file)

Set up a list from a list file.

Parameters:file (str) – Name of the file

New in version 6.2.

License: Geosoft Open License

Note: A list file is an ASCII file that contains list entries. Each line for the file contains a list item name and an optional list item value. The name and value must be delimited by a space, tab or comma. If the item name or value contains spaces, tabs or commas, it must be contined in quotes. blank lines and lines that begin with a ‘/’ character are ignored.

The default extension is .lst. If the file cannot be found in the local directory, the GEOSOFTetc directory is searched. If it cannot be found, the list will be empty. Not finding a file is not an error.

classmethod null()

A null (undefined) instance of GXLST

Returns:A null GXLST
Return type:GXLST
resource(res)

Load a GX List Resource into this list object. The entries are placed at the end of the list and are not sorted.

Parameters:res (str) – Name of the Resource

New in version 5.0.

License: Geosoft Open License

save_file(file)

Save a list to a file.

Parameters:file (str) – Name of the file

New in version 5.0.

License: Geosoft Open License

Note: A list file is an ASCII file that contains list entries. Each line for the file contains a list item name and an optional list item value. The name and value must be delimited by a space, tab or comma. If the item name or value contains spaces, tabs or commas, it must be contined in quotes. blank lines and lines that begin with a ‘/’ character are ignored.

The default extension is .lst. If the file has a full path it will be created as specified. Otherwise we look for the file in the local then the GEOSOFTetc directory. If the file does not exist it will be created in the GEOSOFTetc directory.

select_csv_string_items(buff, ls_to)

Load a GXLST with items from a second GXLST found in a CSV string.

Parameters:
  • buff (str) – Comma separated item names
  • ls_to (GXLST) – GXLST to add selected items to

New in version 5.1.8.

License: Geosoft Open License

Note: Items in the input string must be separated with commas. Parsing uses the sCommaTokens_GS function. Both the name and value of the input GXLST items whose name matches an item in the input string are copied to the output GXLST. Items are copied in the same order they appear in the input string. Items in the string not found in the input GXLST are ignored, and no error is registered. Item matches are case-tolerant.

serial(bf)

Serialize GXLST to a GXBF.

New in version 5.0.

License: Geosoft Open License

set_item(type, item, buff)

Place an item at a specified point in the GXLST.

Parameters:
  • type (int) – LST_ITEM constants data to insert
  • item (int) – Item Number to Set
  • buff (str) – Item to Set

New in version 5.1.5.

License: Geosoft Open License

Note: The existing item at the given index will be replaced.

size()

Get the number of items in the list.

Returns:x - Number of items in the list.
Return type:int

New in version 5.0.

License: Geosoft Open License

sort(type, ord)

Sorts a list.

Parameters:
  • type (int) – LST_ITEM constants data to sort on
  • ord (int) – 0 - Ascending, 1 - Decending

New in version 5.0.

License: Geosoft Open License

LST_ITEM constants

GXLST data access

LST_ITEM_NAME

Access the “Name” part of the GXLST item.

gxapi.LST_ITEM_NAME = 0
LST_ITEM_VALUE

Access the “Value” part of the GXLST item.

gxapi.LST_ITEM_VALUE = 1