Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Jan 1, 2023
1 parent 929a0c7 commit 5f4abe3
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 4 deletions.
7 changes: 3 additions & 4 deletions docs/src/data/spaces.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
a b c,def,g h i
123,4567,890
2468,1357,3579
9987,3312,4543
column 1, column 2, column 3
apple,ball,cat
dale egg,fish,gale
66 changes: 66 additions & 0 deletions docs/src/reference-verbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4078,6 +4078,72 @@ count color shape flag
2 yellow triangle 1
</pre>

## unspace

<pre class="pre-highlight-in-pair">
<b>mlr unspace --help</b>
</pre>
<pre class="pre-non-highlight-in-pair">
Usage: mlr unspace [options]
Replaces spaces in record keys and/or values with _. This is helpful for PPRINT output.
Options:
-f {x} Replace spaces with specified filler character.
-k Unspace only keys, not keys and values.
-v Unspace only values, not keys and values.
-h|--help Show this message.
</pre>

The primary use-case is for PPRINT output, which is space-delimited. For example:

<pre class="pre-highlight-in-pair">
<b>cat data/spaces.csv</b>
</pre>
<pre class="pre-non-highlight-in-pair">
column 1, column 2, column 3
apple,ball,cat
dale egg,fish,gale
</pre>

<pre class="pre-highlight-in-pair">
<b>mlr --icsv --opprint cat data/spaces.csv</b>
</pre>
<pre class="pre-non-highlight-in-pair">
column 1 column 2 column 3
apple ball cat
dale egg fish gale
</pre>

<pre class="pre-highlight-in-pair">
<b>mlr --icsv --opprint cat data/spaces.csv</b>
</pre>
<pre class="pre-non-highlight-in-pair">
column 1 column 2 column 3
apple ball cat
dale egg fish gale
</pre>

<pre class="pre-highlight-in-pair">
<b>mlr --icsv --opprint unspace data/spaces.csv</b>
</pre>
<pre class="pre-non-highlight-in-pair">
column_1 _column_2 _column_3
apple ball cat
dale_egg fish gale
</pre>

<pre class="pre-highlight-in-pair">
<b>mlr --icsv --opprint unspace data/spaces.csv | mlr --ipprint --oxtab cat</b>
</pre>
<pre class="pre-non-highlight-in-pair">
column_1 apple
_column_2 ball
_column_3 cat

column_1 dale_egg
_column_2 fish
_column_3 gale
</pre>

## unsparsify

<pre class="pre-highlight-in-pair">
Expand Down
28 changes: 28 additions & 0 deletions docs/src/reference-verbs.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,34 @@ GENMD-RUN-COMMAND
mlr --opprint uniq -a -c data/repeats.dkvp
GENMD-EOF

## unspace

GENMD-RUN-COMMAND
mlr unspace --help
GENMD-EOF

The primary use-case is for PPRINT output, which is space-delimited. For example:

GENMD-RUN-COMMAND
cat data/spaces.csv
GENMD-EOF

GENMD-RUN-COMMAND
mlr --icsv --opprint cat data/spaces.csv
GENMD-EOF

GENMD-RUN-COMMAND
mlr --icsv --opprint cat data/spaces.csv
GENMD-EOF

GENMD-RUN-COMMAND
mlr --icsv --opprint unspace data/spaces.csv
GENMD-EOF

GENMD-RUN-COMMAND
mlr --icsv --opprint unspace data/spaces.csv | mlr --ipprint --oxtab cat
GENMD-EOF

## unsparsify

GENMD-RUN-COMMAND
Expand Down
10 changes: 10 additions & 0 deletions test/cases/cli-help/0001/expout
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,16 @@ Options:
With -n, produces only one record which is the unique-record count.
With neither -c nor -n, produces unique records.

================================================================
unspace
Usage: mlr unspace [options]
Replaces spaces in record keys and/or values with _. This is helpful for PPRINT output.
Options:
-f {x} Replace spaces with specified filler character.
-k Unspace only keys, not keys and values.
-v Unspace only values, not keys and values.
-h|--help Show this message.

================================================================
unsparsify
Usage: mlr unsparsify [options]
Expand Down
4 changes: 4 additions & 0 deletions test/input/spaces.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a b,c, d e
1,,3
4 5,6, 7 8
9,10,11

0 comments on commit 5f4abe3

Please sign in to comment.