GXLST class¶
-
class
geosoft.gxapi.
GXLST
¶ The LST 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
((str)arg1, (str)arg2) → None:¶ Adds an item to the end of the list.
Parameters: - arg1 (str) – Name of the Item
- arg2 (str) – Value of the Item
Returns: Nothing
Return type: None
New in version 5.0.0.
-
add_symb_item
((str)arg1, (int)arg2) → None:¶ Adds a channel/line/blob name and symbol to a list.
Parameters: - arg1 (str) – Name of the channel, line or blob symbol
- arg2 (int) – symbol handle
Returns: Nothing
Return type: None
New in version 6.2.0.
Note:
A number of DB functions return LSTs with the channel or line name in the "Name" part of a LST, 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
((str)arg1, (str)arg2) → None:¶ Adds a unique item to the end of the list.
Parameters: - arg1 (str) – Name of the Item
- arg2 (str) – Value of the Item
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
Existing items that match the name are first removed.
-
append
((GXLST)arg1) → None:¶ Add the items in one list to another list.
Parameters: arg1 ( geosoft.gxapi.GXLST
) – List to append to the above LST.Returns: Nothing Return type: None New in version 6.2.0.
Note:
Item names and values are added using "
geosoft.gxapi.GXLST.add_unique_item()
", so that existing items with the same name are replaced, and if items are duplicated in the appended LST, the last one will be the one to remain after the process is complete.
-
static
assay_channel
() → GXLST:¶ Create a LST of assay channel mask strings from file.
Returns: LST Object Return type: geosoft.gxapi.GXLST
New in version 5.1.6.
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
-
clear
() → None:¶ Clear a list object.
Returns: Nothing Return type: None New in version 5.0.0.
-
convert_from_csv_string
((str)arg1) → None:¶ Load a LST with items from a string.
Parameters: arg1 (str) – Comma separated items Returns: Nothing Return type: None New in version 5.1.8.
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
((str_ref)arg1) → None:¶ Load a string with names from a LST.
Parameters: arg1 ( geosoft.gxapi.str_ref
) – Buffer to add items toReturns: Nothing Return type: None New in version 5.1.8.
Note:
The list name values are put into a string, items separated by commas.
-
copy
((GXLST)arg1) → None:¶ Copy one LST object to another.
Parameters: arg1 ( geosoft.gxapi.GXLST
) – Source List to Copy fromReturns: Nothing Return type: None New in version 5.0.0.
-
static
create
((int)arg1) → GXLST:¶ creates a user controllable list. The list is empty when created.
Parameters: arg1 (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: geosoft.gxapi.GXLST
New in version 5.0.0.
-
static
create_s
((GXBF)arg1) → GXLST:¶ Create LST from serialized source.
Parameters: arg1 ( geosoft.gxapi.GXBF
) – BFReturns: LST object Return type: geosoft.gxapi.GXLST
New in version 5.0.0.
-
del_item
((int)arg1) → None:¶ Removes an item from the list. All items below it are shifted up one.
Parameters: arg1 (int) – Item Number to Delete Returns: Nothing Return type: None New in version 5.0.0.
-
find_item
((int)arg1, (str)arg2) → int:¶ Searches the list for a specified item.
Parameters: - arg1 (int) – LST_ITEM constants data to do the search on
- arg2 (str) – String to Search For
Returns: x - Item Number -1 - Not Found
Return type: int
New in version 5.0.0.
Note:
Comparisons are case-tolerant.
-
find_item_mask
((int)arg1, (str)arg2) → int:¶ Searches the list for a specified item, list contains masks.
Parameters: - arg1 (int) – LST_ITEM constants data to search
- arg2 (str) – String to try LST mask items on Search For
Returns: x - Item Number -1 - Not Found
Return type: int
New in version 5.1.6.
Note:
Comparsions are case-intolerant (unlike
geosoft.gxapi.GXLST.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 LST 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
-
find_items
((int)arg1, (GXLST)arg2, (GXVV)arg3) → None:¶ Searches a LST for items in a second LST, returns indices of those found.
Parameters: - arg1 (int) – LST_ITEM constants data to do the search on
- arg2 (
geosoft.gxapi.GXLST
) – Items to search for - arg3 (
geosoft.gxapi.GXVV
) – GS_LONG VV of returned indices into the first LST.
Returns: Nothing
Return type: None
New in version 6.3.0.
Note:
This is a much more efficient way of determining if items in one LST are found in a second, than by calling
geosoft.gxapi.GXLST.find_item()
repeatedly in a loop. The returned INT VV contains the same number of items as the "search items" LST, 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
((int)arg1, (int)arg2) → float:¶ Get a real item.
Parameters: - arg1 (int) – LST_ITEM constants data to retrieve
- arg2 (int) – Item Number to Get
Returns: real, rDUMMY if conversion fails or string is empty.
Return type: float
New in version 5.1.2.
-
get_int
((int)arg1, (int)arg2) → int:¶ Get an integer item.
Parameters: - arg1 (int) – LST_ITEM constants data to retrieve
- arg2 (int) – Item Number to Get
Returns: integer, iDUMMY if conversion fails or string is empty.
Return type: int
New in version 5.1.2.
-
gt_item
((int)arg1, (int)arg2, (str_ref)arg3) → None:¶ This places the specified item into the buffer provided.
Parameters: - arg1 (int) – LST_ITEM constants data to retrieve
- arg2 (int) – Item Number to Get
- arg3 (
geosoft.gxapi.str_ref
) – Buffer to Place Item Into
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
If item number is not in the list, the buffer will be "".
-
gt_symb_item
((int)arg1, (str_ref)arg2, (int_ref)arg3) → None:¶ Returns a channel/line/blob name and symbol from a list.
Parameters: - arg1 (int) – Item number to get
- arg2 (
geosoft.gxapi.str_ref
) – Buffer to Place Symbol name into - arg3 (
geosoft.gxapi.int_ref
) – Symbol handle
Returns: Nothing
Return type: None
New in version 6.3.0.
Note:
A number of DB functions return LSTs with the channel or line name in the "Name" part of a LST, 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
((int)arg1, (str)arg2, (str)arg3) → None:¶ Adds an item at a given location in the list.
Parameters: - arg1 (int) – Item index
- arg2 (str) – Name of the Item
- arg3 (str) – Value of the Item
Returns: Nothing
Return type: None
New in version 5.1.6.
Note:
Index must be 0 >= index >= list size. Items above the list index are shifted up one index value.
-
is_null
() → bool¶ Check if the instance of
geosoft.gxapi.GXLST is null (undefined)
Returns: True if this is a null instance of geosoft.gxapi.GXLST
, False otherwise.Return type: bool`
-
load_csv
((str)arg1, (str)arg2, (str)arg3) → None:¶ Load a list with data from a CSV file
Parameters: - arg1 (str) – The CSV file
- arg2 (str) – column label for the item name
- arg3 (str) – column label for the item value
Returns: Nothing
Return type: None
New in version 5.0.0.
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
((str)arg1) → None:¶ Set up a list from a list file.
Parameters: arg1 (str) – name of the file Returns: Nothing Return type: None New in version 6.2.0.
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. This function replaces the
geosoft.gxapi.GXLST.load_file()
function which actually always returned 0, or terminated on an error.
-
static
null
() → GXLST¶ A null (undefined) instance of
geosoft.gxapi.GXLST
Returns: A null geosoft.gxapi.GXLST
Return type: geosoft.gxapi.GXLST
-
resource
((str)arg1) → None:¶ Load a GX List Resource into this list object. The entries are placed at the end of the list and are not sorted.
Parameters: arg1 (str) – Name of the Resource Returns: Nothing Return type: None New in version 5.0.0.
-
save_file
((str)arg1) → None:¶ Save a list to a file.
Parameters: arg1 (str) – name of the file Returns: Nothing Return type: None New in version 5.0.0.
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
((str)arg1, (GXLST)arg2) → None:¶ Load a LST with items from a second LST found in a CSV string.
Parameters: - arg1 (str) – Comma separated item names
- arg2 (
geosoft.gxapi.GXLST
) – LST to add selected items to
Returns: Nothing
Return type: None
New in version 5.1.8.
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 LST items whose name matches an item in the input string are copied to the output LST. Items are copied in the same order they appear in the input string. Items in the string not found in the input LST are ignored, and no error is registered. Item matches are case-tolerant.
-
serial
((GXBF)arg1) → None:¶ Serialize LST to a BF.
Parameters: arg1 ( geosoft.gxapi.GXBF
) – BFReturns: Nothing Return type: None New in version 5.0.0.
-
set_item
((int)arg1, (int)arg2, (str)arg3) → None:¶ Place an item at a specified point in the LST.
Parameters: - arg1 (int) – LST_ITEM constants data to insert
- arg2 (int) – Item Number to Set
- arg3 (str) – Item to Set
Returns: Nothing
Return type: None
New in version 5.1.5.
Note:
The existing item at the given index will be replaced.
-
size
() → int:¶ Get the number of items in the list.
Returns: x - Number of items in the list. Return type: int New in version 5.0.0.
-
sort
((int)arg1, (int)arg2) → None:¶ Sorts a list.
Parameters: - arg1 (int) – LST_ITEM constants data to sort on
- arg2 (int) – 0 - Ascending, 1 - Decending
Returns: Nothing
Return type: None
New in version 5.0.0.
-