Linefuncs Documentation

This page contains the Linefuncs Module documentation. See also How to get your data into the database.

The linefuncs Module

Line functions are helper functions available to use in the mapping file.

All importable line functions take ‘linedata’ as a first argument. This is either a line or a block of text data from the currently parsed input file.

Example of call from mapping dictionary:

{‘cname’ : ‘whatever_field_name’,
‘cbyte’ : (charrange, 56, 58)}
imptools.linefuncs.bySepNr(linedata, number, sep=', ')
imptools.linefuncs.bySepNr2(linedata, number, sep=', ')

Split a text line by sep argument and return the number:ed split section

Inputs:
linedata (str or iterable) - current line(s) to operate on number (int) - nth section, separated by sep sep (str) - a separator to split by
imptools.linefuncs.bySepNr2int(linedata, number, sep=', ')

Split a text line by sep aargument and return the numbered split section. Always convert output to int. Inputs:

linedata (str) number (int) - nth section, separated by sep sep (str) - separator to split by
imptools.linefuncs.charrange(linedata, start, end)

Cut out part of a line of texts based on indices.

Inputs:
linedata (str or iterable) - current line(s) to operate on start, end (int) - beginning and end indices of the line
imptools.linefuncs.charrange2int(linedata, start, end)

Cut out part of a line based on indices, return as integer

Inputs:
linedata (str or iterable) - current line(s) to operate on start, end (int) - beginning and end indices of the line
imptools.linefuncs.constant(linedata, value)
imptools.linefuncs.get_accur(linedata, range1, range2)

extract accuracy

imptools.linefuncs.get_alphawaals(linedata, sep1, sep2)

extract alpha - van der waal value

imptools.linefuncs.get_gammawaals(linedata, sep1, sep2)

extract gamma - van der waal value

imptools.linefuncs.get_publications(linedata)

extract publication data. This returns a list since it is for a multi-reference.

imptools.linefuncs.get_sigmawaals(linedata, sep1, sep2)

extract sigma - van der waal value

imptools.linefuncs.get_srcfile_ref(linedata, sep1, sep2)

extract srcfile reference

imptools.linefuncs.get_term_val(linedata, varname)
extract configurations from term file.
varname is the value type we want (e.g. s or l); we search the identifyer field of the
term-file to see if it exists and return the corresponding value, otherwise we return ‘X’. Varname is case insensitive.
imptools.linefuncs.is_iter(iterable)

Helper function

Checks if the given argument is iterable or not, i.e. if it is a list or tuple. Strings are not considered iterable by this function.

imptools.linefuncs.lineSplit(linedata, splitsep=', ')

Splits a line by splitsep, returns a list. The main use for this method is creating a many-to-many reference.

Inputs:
linedata (str or iterable) - current line(s) to operate on splitsep (str) - string to split by

Returns a list!

imptools.linefuncs.merge_cols(linedata, *ranges)
Merges data from several columns into one, separating them with ‘-‘.
ranges are any number of tuples (indexstart, indexend) defining the columns.
imptools.linefuncs.merge_cols_by_sep(linedata, *sepNr)

Merges data from several columns (separated by ;) into one, separating them with ‘-‘. sepNr are the nth position of the file, separated by ‘sep’. Assumes a single line input.