-
Notifications
You must be signed in to change notification settings - Fork 0
Home
STELETO is a simple command line application to convert tabular (delimited text) data into other textual formats, via a custom template. It takes a data file as input, applies the specified template and creates a text file as output. For further details of the template syntax see http://www.stringtemplate.org/
Some example comma-delimited text input (save as 'c:\tmp\mydata.csv'):
ref,name,qty
A1234,apples,5127
A2345,bananas,235
A3456,pears,8756
An example template to be applied to each row in the input data (save as 'c:\tmp\data2text.stg'):
// start of the template
delimiters "{", "}"
RECORD(data, options) ::= <<
Reference : {data.ref}
Description : {data.name} [{data.qty}]
>>
// end of the template
Command to perform the conversion (STELETO -h for help):
cd \path\to\steleto
STELETO -i:"c:\tmp\mydata.csv" -o:"c:\tmp\output.txt" -t:"c:\tmp\data2text.stg" -f -d:","
The STELETO parameters may be present in any order:
-i [required] - the name of the input data file (including path)
-o [required] - the name of the output data file (including path)
-t [required] - the name of the template file (including path)
-f [optional] - indicates the first line of the input data contains field names
-d [optional] - indicates the delimiter used in the input data (default is tab delimited)
-p [optional] - any additional named parameter options passed to the template (-p:name:value)
Contents of the resultant output file (c:\tmp\output.txt):
Reference : A1234
Description : apples [5127]
Reference : A2345
Description : bananas [235]
Reference : A3456
Description : pears [8756]
Now an alternative template, to create some XML from the same input data (save as 'c:\tmp\data2xml.stg'):
// start of the template
delimiters "{", "}"
HEADER(options) ::= <<
<?xml version="1.0" encoding="UTF-8"?>
<items>
>>
RECORD(data, options) ::= <<
<item rdf:about="{options.uri}{data.reference}">
<reference>{data.ref}</reference>
<description>{data.name}</description>
<quantity>{data.qty}</quantity>
</item>
>>
FOOTER(options) ::= "</items>"
// end of the template
Command to perform the conversion:
STELETO -i:"c:\tmp\mydata.csv" -o:"c:\tmp\output.xml" -t:"c:\tmp\data2xml.stg" -f -d:"," -p:uri:"http://temp1/"
Contents of the resultant output file (c:\tmp\output.xml):
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item rdf:about="http://temp1/A1234">
<description>apples</description>
<quantity>5127</quantity>
</item>
<item rdf:about="http://temp1/A2345">
<description>bananas</description>
<quantity>235</quantity>
</item>
<item rdf:about="http://temp1/A3456">
<description>pears</description>
<quantity>8756</quantity>
</item>
</items>