Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsv-select --exclude #267

Merged
merged 9 commits into from
Mar 2, 2020
Prev Previous commit
Next Next commit
tsv-select documentation updates.
  • Loading branch information
jondegenhardt committed Mar 2, 2020
commit 4483453205fa6e70fb3a083b93cc951e5f038fab
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,31 @@ See the [tsv-filter reference](docs/ToolReference.md#tsv-filter-reference) for m

### tsv-select

A version of the Unix `cut` utility with the additional ability to re-order the fields. It also helps with header lines by keeping only the header from the first file (`--header` option). The following command writes fields [4, 2, 9, 10, 11] from a pair of files to stdout:
A version of the Unix `cut` utility with the additional ability to re-order the fields. The following command writes fields [4, 2, 9, 10, 11] from a pair of files to stdout:
```
$ tsv-select -f 4,2,9-11 file1.tsv file2.tsv
```

Fields can be listed more than once, and fields not listed can be output using the `--rest` option. When working with multiple files, the `--header` option can be used to retain only the header from the first file.

Examples:
```
$ # Output fields 2 and 1, in that order
$ tsv-select -f 2,1 data.tsv

$ # Move field 7 to the start of the line
$ tsv-select -f 7 --rest last data.tsv

$ # Move field 1 to the end of the line
$ tsv-select -f 1 --rest first data.tsv

$ # Output a range of fields in reverse order
$ tsv-select -f 30-3 data.tsv

$ # Multiple files with header lines. Keep only one header.
$ tsv-select data*.tsv -H --fields 1,2,4-7,14
```

See the [tsv-select reference](docs/ToolReference.md#tsv-select-reference) for details.

### tsv-uniq
Expand Down
2 changes: 1 addition & 1 deletion docs/ToolReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Fields numbers start with one. They are comma separated, and ranges can be used.
**Examples:**
```
$ # Output fields 2 and 1, in that order
$ tsv-select -f 2,1 --rest first data.tsv
$ tsv-select -f 2,1 data.tsv

$ # Move field 1 to the end of the line
$ tsv-select -f 1 --rest first data.tsv
Expand Down
22 changes: 21 additions & 1 deletion tsv-select/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,31 @@ _Visit the eBay TSV utilities [main page](../README.md)_

# tsv-select

A version of the Unix `cut` utility with the additional ability to re-order the fields. It also helps with header lines by keeping only the header from the first file (`--header` option). The following command writes fields [4, 2, 9, 10, 11] from a pair of files to stdout:
A version of the Unix `cut` utility with the additional ability to re-order the fields. The following command writes fields [4, 2, 9, 10, 11] from a pair of files to stdout:
```
$ tsv-select -f 4,2,9-11 file1.tsv file2.tsv
```

Fields can be listed more than once, and fields not listed can be output using the `--rest` option. When working with multiple files, the `--header` option can be used to retain only the header from the first file.

Examples:
```
$ # Output fields 2 and 1, in that order
$ tsv-select -f 2,1 data.tsv

$ # Move field 7 to the start of the line
$ tsv-select -f 7 --rest last data.tsv

$ # Move field 1 to the end of the line
$ tsv-select -f 1 --rest first data.tsv

$ # Output a range of fields in reverse order
$ tsv-select -f 30-3 data.tsv

$ # Multiple files with header lines. Keep only one header.
$ tsv-select data*.tsv -H --fields 1,2,4-7,14
```

Reordering fields and managing headers are useful enhancements over `cut`. However, much of the motivation for writing it was to explore the D programming language and provide a comparison point against other common approaches to this task. Code for `tsv-select` is bit more liberal with comments pointing out D programming constructs than code for the other tools. As an unexpected benefit, `tsv-select` is faster than other implementations of `cut` that are available.

See the [tsv-select reference](../docs/ToolReference.md#tsv-select-reference) for details.
2 changes: 1 addition & 1 deletion tsv-select/src/tsv_utils/tsv-select.d
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Examples:
Notes:
* One of '--f|fields' or '--e|exclude' is required.
* Fields specified by '--f|fields' and '--e|exclude' cannot overlap.
* Each line must have all fields specfied by '--f|fields'. Otherwise
* Each line must have all fields specified by '--f|fields'. Otherwise
line length can vary.

Options:
Expand Down