App-combinesheets
view release on metacpan or search on metacpan
the *configuration* section. In both cases, the value of the standard
output of these programs become the value of the calculated column (a
trailing newline of this standard output is removed and other newlines
are replaced by spaces).
A program defined by the PROGS is called without any arguments ("S" in
*PROGS* stands for a *Simple*). That's why it does not have any
knowledge for which row it has been invoked. Its usage is, therefore,
for column values that are not dependent on other values from the
spreadsheet. For example, for the "cars.tsv" shown above, you can add a
column "Last updated" by calling a UNIX program "date" - again, see an
example the *configuration* section.
A program defined by the PROG is called with one argument which is a
filename. This file contains the current row; each of its lines has two,
TAB-separated, fields. The first field is the column name and the second
field is the column value. For example, when processing the last row of
the "cars.tsv" given above, the file will have the following content:
Model Skoda
Year 2002
Owned by Model Year Car age
Gudernova Mini 1968 44
Senger Skoda 2002 10
Someone else Praga 1936 76
You can see that there is no need to use "combinesheets" for really
combining *more* sheets, an input can be just one sheet.
Another example adds a *fixed* column to the same input, a column
named *Last updated* that gets its value from a UNIX command "date".
This program does not get any information which row it has been
invoked for. The configuration file is now (note the new line with
the PROGS):
MATCH CAR=Owned by
CAR Owned by
CAR Model
CAR Year
PROG age.sh Car age
PROGS date Last updated
and the result is now:
Owned by Model Year Car age Last updated
Gudernova Mini 1968 44 Mon Feb 27 12:32:04 AST 2012
Senger Skoda 2002 10 Mon Feb 27 12:32:04 AST 2012
Someone else Praga 1936 76 Mon Feb 27 12:32:04 AST 2012
The last possibility is to call a Perl subroutine - using the
reserved word PERL in the configuration file. Let's have an input
spreadsheet ("flights.tsv") with data about flights:
Date Flight Airport From Airport To
2009-01-18 AY838 London LHR Helsinki Vantaa
docs/App-combinesheets.html view on Meta::CPAN
<p>Each <code>calculated column</code> is created either by an external, command-line driven, program, or by a Perl subroutine. In both cases, the user must create (write) such external program or such Perl subroutine. Therefore, this usage is meant ...
<p>Note that this advanced feature is meant only for new columns, not for new rows. Therefore, it cannot be used, for example, to create rows with totals of columns.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="Calculated_columns_by_external_programs"
>Calculated columns by external programs</a></h2>
<p>If specified, an external program is invoked for each row. It can be specified either by a keyword <b>PROG</b> or by a keyword <b>PROGS</b> - see syntax in the <i>configuration</i> section. In both cases, the value of the standard output of these ...
<p>A program defined by the <b>PROGS</b> is called without any arguments (<code>S</code> in <i>PROGS</i> stands for a <i>Simple</i>). That's why it does not have any knowledge for which row it has been invoked. Its usage is, therefore, for column...
<p>A program defined by the <b>PROG</b> is called with one argument which is a filename. This file contains the current row; each of its lines has two, TAB-separated, fields. The first field is the column name and the second field is the column value...
<pre> Model Skoda
Year 2002
Owned by Senger</pre>
<p>The files are only temporary and will be removed when <code>combinesheets</code> finishes.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
docs/App-combinesheets.html view on Meta::CPAN
<p>we get this result:</p>
<pre> Owned by Model Year Car age
Gudernova Mini 1968 44
Senger Skoda 2002 10
Someone else Praga 1936 76</pre>
<p>You can see that there is no need to use <code>combinesheets</code> for really combining <i>more</i> sheets, an input can be just one sheet.</p>
<p>Another example adds a <i>fixed</i> column to the same input, a column named <i>Last updated</i> that gets its value from a UNIX command <code>date</code>. This program does not get any information which row it has been invoked for. The configurat...
<pre> MATCH CAR=Owned by
CAR Owned by
CAR Model
CAR Year
PROG age.sh Car age
PROGS date Last updated</pre>
<p>and the result is now:</p>
<pre> Owned by Model Year Car age Last updated
Gudernova Mini 1968 44 Mon Feb 27 12:32:04 AST 2012
Senger Skoda 2002 10 Mon Feb 27 12:32:04 AST 2012
Someone else Praga 1936 76 Mon Feb 27 12:32:04 AST 2012</pre>
<p>The last possibility is to call a Perl subroutine - using the reserved word <b>PERL</b> in the configuration file. Let's have an input spreadsheet (<code>flights.tsv</code>) with data about flights:</p>
<pre> Date Flight Airport From Airport To
2009-01-18 AY838 London LHR Helsinki Vantaa
2009-01-22 AY839 Helsinki Vantaa London LHR
2009-03-15 NW2 Manila Tokyo Narita
examples/cars.cfg view on Meta::CPAN
MATCH CAR=Owned by
CAR Owned by
CAR Model
CAR Year
PROG age.sh Car age
PROGS date Last updated
lib/App/combinesheets.pm view on Meta::CPAN
syntax in the I<configuration> section. In both cases, the
value of the standard output of these programs become the value of the
calculated column (a trailing newline of this standard output is
removed and other newlines are replaced by spaces).
A program defined by the B<PROGS> is called without any arguments
(C<S> in I<PROGS> stands for a I<Simple>). That's why it does not have
any knowledge for which row it has been invoked. Its usage is,
therefore, for column values that are not dependent on other values
from the spreadsheet. For example, for the C<cars.tsv> shown above,
you can add a column C<Last updated> by calling a UNIX program C<date>
- again, see an example the I<configuration>
section.
A program defined by the B<PROG> is called with one argument which is
a filename. This file contains the current row; each of its lines has
two, TAB-separated, fields. The first field is the column name and the
second field is the column value. For example, when processing the
last row of the C<cars.tsv> given above, the file will have the
following content:
lib/App/combinesheets.pm view on Meta::CPAN
Owned by Model Year Car age
Gudernova Mini 1968 44
Senger Skoda 2002 10
Someone else Praga 1936 76
You can see that there is no need to use C<combinesheets> for really
combining I<more> sheets, an input can be just one sheet.
Another example adds a I<fixed> column to the same input, a column
named I<Last updated> that gets its value from a UNIX command
C<date>. This program does not get any information which row it has
been invoked for. The configuration file is now (note the new line
with the B<PROGS>):
MATCH CAR=Owned by
CAR Owned by
CAR Model
CAR Year
PROG age.sh Car age
PROGS date Last updated
and the result is now:
Owned by Model Year Car age Last updated
Gudernova Mini 1968 44 Mon Feb 27 12:32:04 AST 2012
Senger Skoda 2002 10 Mon Feb 27 12:32:04 AST 2012
Someone else Praga 1936 76 Mon Feb 27 12:32:04 AST 2012
The last possibility is to call a Perl subroutine - using the reserved
word B<PERL> in the configuration file. Let's have an input
spreadsheet (C<flights.tsv>) with data about flights:
Date Flight Airport From Airport To
2009-01-18 AY838 London LHR Helsinki Vantaa
( run in 0.318 second using v1.01-cache-2.11-cpan-05444aca049 )