HTML automatically generated with rman
Table of Contents
txtpar - extract parameters from a text file, with optional math
in=text-file p0= p1= ...
txtpar combines some of the often used
combinations of standard Unix text filtering programs like grep(1)
, with nemoinp(3NEMO)
style math into one "simple" NEMO program.
can do some of this processing too, txtpar(1NEMO)
strength is processing multiple lines in a reduction style, instead of
Normally one parameter is extracted per p#= directive, in a word,row,col
fashion. Future option will allow multiple col’s , but this is not implemented
Comment lines in the input file are considered part of the text, they
are not stripped out. Use tabcomment(1NEMO)
first if you really need them
Optionally additional math is allowed on the extracted parameters
style expressions. In this case, the parameters themselves
are not output, but only the ones computed via expr=. See EXAMPLES below
if you need both.
The following parameters are recognized in
order; they may be given in any order if the keyword is also given. Use
--help to confirm this man page is up to date.
Here is an example
of extracting three values and converting them to two output values:
- input text file,
containing marker words and numeric values to be parsed. No default.
- Optional expression(s), separated by commas, referencing the extracted
parameters via the fie(3NEMO)
parsing rules. By default no expression is
needed and each parameter is output as they appeared in the text file,
however when expr= is used, only those newly computed values are output.
[Default: no expression given]
- A (printf(3)
specification applied to the computed expressions with which the parameters
are written to output [Default: %g].
- Integer initial seed in case
random numbers have been used in the expression. If 0 is given, the time
of the day will be used (see xrandom(3NEMO)
for other special seed values)
to initialize the random number generator. [Default: 0].
a newline be used between output values. [Default: f]
- In case
a NEMO/unix pipe is used, the maximum number of lines will need to be specified.
- Parameter selection directive in the
indexed keyword notation (e.g. p0=, p1=, p2=), see getparam(3NEMO)
. word is
the string to search on (with some limited grep syntax), but can be blank
if all lines need to apply. row is an integer, and is the row-th occurance
from the word match. 1 would be the first, 2 the 2nd, -1 the last, -2 the
one but last etc. 0 is not an allowed row number. col is an integer, and
designates the "column" to look for in the current row (line), 1 would
be the first word, -1 the last etc. Multiple col will be allowed in a future
version, but currently not available. 0 is not an allowed col number.
least one parameter needs to be given: p0=.
txtpar in=example.txt expr="log(abs(%1)),log(abs(%3/%2))" format=%.3f
p1=Worst,1,9 p2=QAC,1,3 par3=QAC,1,4
Worst fractional energy loss dE/E = (E_t-E_0)/E_0 = 0.00146761 at
T = 1.28125
QAC_STATS: - 0.039966 0.0274195 0.00185505 0.135854 0.799319 1 20
If both original values as well as newly computed expr= are desired in
the output (this is the default behavior in tabmath(1NEMO)
), an extra pipe
) is needed. Here is an example to add the first column
in the first two lines of a table in both forms, with and without the original
txtpar example.txt p0=1,1 p1=2,1 | tabmath - - %1+%2 format=%.3f
txtpar example.txt %1+%2 %.3f p0=1,1 p1=2,1
This program is not intended for streaming very large files, as
the file is read into memory for processing and each parameter could potentially
cause a search through the file.
27-dec-2021 V0.1 simple draft written - implemented simple version PJT
Table of Contents