[Radiance-general] rcalc and tabs/spaces

Greg Ward gregoryjward at gmail.com
Tue Jun 6 07:49:42 PDT 2017


Hi Victor,

I am not sure there is a way to do what you are asking with rcalc.  You can use input fields rather than separators with an input format, e.g.:

	rcalc -i '${n1},${n2},$(s3),${n4}'

This loads the first two comma-separated values as numbers, the third as a string, and the fourth as a number again.  (This is the difference between using curly braces and parentheses in rcalc format fields.)  However, there is not much you can do with string fields other than repeat them in the output.  They cannot be the arguments or results of any expressions or formulas.  Generally, they are simply used as place-holders or a means to repeat the input in the output using a similarly constructed output format (-o option).

You could use the "cond" variable to decide whether to output a record or not in your example, like so:

	rcalc -i '${n1},${n2},$(s3),${n4}' -e 'cond=n2-n1' -o '$(s3)'

This would only output the third field when the second is greater than the first.  It would not output "0" otherwise, but no line at all.

I don't know if this helps.

-Greg

> From: Victor LRG <rioboo at gmail.com>
> Date: June 6, 2017 7:02:59 AM PDT
> 
> Dear all,
> 
> The man page for rcalc says "By default, tabs and spaces are ignored except as field separators". I wonder if there is a way to overrule this default behavior. For example:
> 
> echo 1,2,3 4,5 | rcalc -t, -e '$1=if($2-$1,$3,0)' gives '3' as result. Can it be forced to give '3 4'?
> 
> In this case the space is not a field separator, but it causes the rest of the field be missing from the ouput.
> 
> Many thanks,
> 
> Victor Lopez-Rioboo Gil
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.radiance-online.org/pipermail/radiance-general/attachments/20170606/b04f9043/attachment.html>


More information about the Radiance-general mailing list