- Difficulty level: easy
- Time need to lean: 10 minutes or less
- Key points:
- Option
pattern
creates variables from input files
- Option
Option pattern
uses named wildcards to match pattern to all input files, and creates step variables for these wildcard objects. That is to say, with step_input='a-20.txt', 'b-10.txt'
and pattern = '{name}-{par}.txt'
as in the following example, SoS creates
name=['a', 'b']
par=['20', '10']
Then, with the help from another function expand_pattern
that creates multiple names from array variables, we can join the arrays to create _output
a-processed-20.txt
andb-processed-20.txt
A side effect of pattern
is that the extracted variables are automatically paired_with
input files, which, in addition to variables such as name
and par
, with create variables _name
and _par
for each substep.
That is to say, if substeps are defined with option group_by
(or for_each
), the expand_pattern
should use variables _name
and _par
to create the right _output
for each substep: