Skip to end of metadata
Go to start of metadata

csv-eval can now be used to update csv stream values in place. Simply assign new values to input stream fields. For example,

$ ( echo 1,0.1,cat; echo 2,0.01,dog )
1,0.1,cat
2,0.01,dog
$ ( echo 1,0.1,cat; echo 2,0.01,dog ) | csv-eval --fields=,x --format=,d 'x = x**2'
1,0.01,cat
2,0.0001,dog
$ ( echo 1,0.1,cat; echo 2,0.01,dog ) | csv-to-bin ui,d,s[3] | csv-eval --fields=,x --binary=ui,d,s[3] 'x = x**2' | csv-from-bin ui,d,s[3]
1,0.01,cat
2,0.0001,dog

It is also possible to update input stream and append new value simultaneously. For example,

$ ( echo 1,0.1,cat; echo 2,0.01,dog ) | csv-eval --fields=,x --format=,d 'x = x**2; flag = (x < 0.001)' --output-format=flag --output-format=ub
1,0.01,cat,0
2,0.0001,dog,1

Note that --output-fields and --output-format apply to appended fields only. Input fields and input format remain fixed.

  • No labels