[Radiance-general] rcalc and tabs/spaces

Andy McNeil mcneil.andrew at gmail.com
Wed Jun 7 15:03:57 PDT 2017


Hi Victor,

If you are using linux or mac, this sort of thing is simple with awk. There
might be an equivalent with windows.

echo 1,2,3 4,5 | awk -F, '{if($2>$1)print $3;else print 0}'
output:
3 4

Andy

On Tue, Jun 6, 2017 at 7:49 AM, Greg Ward <gregoryjward at gmail.com> wrote:

> 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
>
>
> _______________________________________________
> Radiance-general mailing list
> Radiance-general at radiance-online.org
> https://www.radiance-online.org/mailman/listinfo/radiance-general
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.radiance-online.org/pipermail/radiance-general/attachments/20170607/1b3b740a/attachment.html>


More information about the Radiance-general mailing list