GXLST class¶
- class GXLST(handle=0)[source]¶
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)[source]¶
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)[source]¶
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 aGXLST
, 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)[source]¶
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)[source]¶
Add the items in one list to another list.
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 appendedGXLST
, the last one will be the one to remain after the process is complete.
- classmethod assay_channel()[source]¶
Create a
GXLST
of assay channel mask strings from file.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
- clear()[source]¶
Clear a list object.
New in version 5.0.
License: Geosoft Open License
- convert_from_csv_string(buff)[source]¶
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)[source]¶
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)[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)[source]¶
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:
New in version 5.0.
License: Geosoft Open License
- classmethod create_s(bf)[source]¶
Create
GXLST
from serialized source.New in version 5.0.
License: Geosoft Open License
- del_item(item)[source]¶
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)[source]¶
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)[source]¶
Searches the list for a specified item, list contains masks.
- Parameters:
type (int) – LST_ITEM constants data to search
name (str) – String to try
GXLST
mask items on Search For
- 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 themselvesThis 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(type, lst2, vv)[source]¶
Searches a
GXLST
for items in a secondGXLST
, 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 callingfind_item
repeatedly in a loop. The returned INTGXVV
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)[source]¶
Get a real item.
- Parameters:
type (int) – LST_ITEM constants data to retrieve
item (int) – Item Number to Get
- 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)[source]¶
Get an integer item.
- Parameters:
type (int) – LST_ITEM constants data to retrieve
item (int) – Item Number to Get
- 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)[source]¶
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)[source]¶
Returns a channel/line/blob name and symbol from a list.
- Parameters:
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 aGXLST
, 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)[source]¶
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()[source]¶
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)[source]¶
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)[source]¶
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.
- resource(res)[source]¶
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)[source]¶
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)[source]¶
Load a
GXLST
with items from a secondGXLST
found in a CSV string.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 outputGXLST
. Items are copied in the same order they appear in the input string. Items in the string not found in the inputGXLST
are ignored, and no error is registered. Item matches are case-tolerant.
- serial(bf)[source]¶
-
New in version 5.0.
License: Geosoft Open License
- set_item(type, item, buff)[source]¶
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()[source]¶
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)[source]¶
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