# HG changeset patch # User František Kučera # Date 1620764808 -7200 # Node ID ab7f333f1225547b16ac297af153e8eabc41a66c # Parent 4560c5623d7d02c677ff2e1bc6b7b30a0f28051b relpipe-tr-cut has new syntax since v0.18: --relation, --attribute diff -r 4560c5623d7d -r ab7f333f1225 relpipe-data/examples-apt.xml --- a/relpipe-data/examples-apt.xml Tue May 11 21:35:54 2021 +0200 +++ b/relpipe-data/examples-apt.xml Tue May 11 22:26:48 2021 +0200 @@ -41,7 +41,7 @@

And print results in a pretty table:

@@ -86,7 +86,7 @@ apt-packages.fods]]> diff -r 4560c5623d7d -r ab7f333f1225 relpipe-data/examples-grep-cut-fstab.xml --- a/relpipe-data/examples-grep-cut-fstab.xml Tue May 11 21:35:54 2021 +0200 +++ b/relpipe-data/examples-grep-cut-fstab.xml Tue May 11 22:26:48 2021 +0200 @@ -29,7 +29,7 @@ We can put away the a attribute from the numbers relation:

- cat both.rp | relpipe-tr-cut 'numbers' 'b|c' | relpipe-out-tabular + cat both.rp | relpipe-tr-cut --relation 'numbers' --attribute 'b|c' | relpipe-out-tabular

and leave the letters relation unaffected:

@@ -112,7 +112,7 @@

Or we can remove a from both relations resp. keep there only attributes whose names match 'b|c' regex:

- cat both.rp | relpipe-tr-cut '.*' 'b|c' | relpipe-out-tabular + cat both.rp | relpipe-tr-cut --relation '.*' --attribute 'b|c' | relpipe-out-tabular

Instead of '.*' we could use 'numbers|letters' and in this case it will give the same result:

@@ -136,7 +136,9 @@

All the time, we are reducing the attributes. But we can also multiply them or change their order:

- cat both.rp | relpipe-tr-cut 'numbers' 'b|a|c' 'b' 'a' 'a' | relpipe-out-tabular + cat both.rp \ + | relpipe-tr-cut --relation 'numbers' --attribute 'b|a|c' --attribute 'b' --attribute 'a' --attribute 'a' \ + | relpipe-out-tabular

n.b. the order in 'b|a|c' does not matter and if such regex matches, it preserves the original order of the attributes; @@ -162,7 +164,7 @@ Record count: 2]]>

- The letters relation stays rock steady and relpipe-tr-cut 'numbers' does not affect it in any way. + The letters relation stays rock steady and relpipe-tr-cut --relation 'numbers' does not affect it in any way.

Process CSV files

@@ -195,7 +197,7 @@

and get result like this:

diff -r 4560c5623d7d -r ab7f333f1225 relpipe-data/examples-in-xmltable-ssm-gui.xml --- a/relpipe-data/examples-in-xmltable-ssm-gui.xml Tue May 11 21:35:54 2021 +0200 +++ b/relpipe-data/examples-in-xmltable-ssm-gui.xml Tue May 11 22:26:48 2021 +0200 @@ -39,8 +39,8 @@ Thanks to regular expressions, it is very concise. But of course, we can make it more explicit:

- +

We also set the window title (using the -title Qt option) and get the chart:

diff -r 4560c5623d7d -r ab7f333f1225 relpipe-data/examples/ssm-xmltable-1.makefile --- a/relpipe-data/examples/ssm-xmltable-1.makefile Tue May 11 21:35:54 2021 +0200 +++ b/relpipe-data/examples/ssm-xmltable-1.makefile Tue May 11 22:26:48 2021 +0200 @@ -17,4 +17,4 @@ cat build/statistics.rp | relpipe-out-tabular statistics-chart: build/statistics.rp - cat build/statistics.rp | relpipe-tr-cut ".*" "(name|.*s)" | relpipe-out-gui -title "Sane software manifesto – chart of rule types" + cat build/statistics.rp | relpipe-tr-cut --relation ".*" --attribute "(name|.*s)" | relpipe-out-gui -title "Sane software manifesto – chart of rule types" diff -r 4560c5623d7d -r ab7f333f1225 relpipe-data/streamlets-preview.xml --- a/relpipe-data/streamlets-preview.xml Tue May 11 21:35:54 2021 +0200 +++ b/relpipe-data/streamlets-preview.xml Tue May 11 22:26:48 2021 +0200 @@ -45,9 +45,9 @@ --as 'ocr_text' \ --streamlet pdftotext --as 'pdf_text' \ | relpipe-tr-awk \ - --relation filesystem \ + --relation 'filesystem' \ --where 'path ~ /\.sh$/ || url ~ /alt2xml\.globalcode\.info/ || ocr_text ~ /GNU/ || pdf_text ~ /Sane/' \ - | relpipe-tr-cut filesystem 'path|url|width|height|page_count|lines_count' \ + | relpipe-tr-cut --relation 'filesystem' --attribute 'path|url|width|height|page_count|lines_count' \ | relpipe-out-tabular # if too wide, add: | less -RSi]]>