eBay / tsv-utils

eBay's TSV Utilities: Command line tools for large, tabular data files. Filtering, statistics, sampling, joins and more.
https://ebay.github.io/tsv-utils/
Boost Software License 1.0
1.43k stars 80 forks source link

Experimental named field support in tsv-select #284

Closed jondegenhardt closed 4 years ago

jondegenhardt commented 4 years ago

This PR adds experimental named field support to tsv-select. Assume a file with the header fields:

 1    run
 2    elapsed_time
 3    user_time
 4    system_time
 5    max_memory

Commands like the following can be used:

$ tsv-select data.tsv -H -f user_time           # Field  3
$ tsv-select data.tsv -H -f run,user_time       # Fields 1,3
$ tsv-select data.tsv -H -f run-user_time       # Fields 1,2,3
$ tsv-select data.tsv -H -f '*_memory'          # Field  5
$ tsv-select data.tsv -H -f '*_time'            # Fields 2,3,4
$ tsv-select data.tsv -H -f '*_time,*_memory'   # Fields 2,3,4,5
$ tsv-select data.tsv -H -f '*_memory,*_time'   # Fields 5,2,3,4

Field exclusions work also:

$ tsv-select data.tsv -H -e user_time           # Exclude field  3
$ tsv-select data.tsv -H -e '*_time'            # Exclude fields 2,3,4

Numeric field numbers can be used as before:

$ tsv-select data.tsv -H -f 3                   # Field 3

Support for the feature is complete for tsv-select, but it is not documented yet, including in the help message. Documentation, including help documentation, will be done after named fields have been added to the other tools and a release performed.

Another steps towards enhancement request #25

codecov-commenter commented 4 years ago

Codecov Report

Merging #284 into master will increase coverage by 0.04%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #284      +/-   ##
==========================================
+ Coverage   99.28%   99.32%   +0.04%     
==========================================
  Files          17       18       +1     
  Lines        5980     6512     +532     
==========================================
+ Hits         5937     6468     +531     
- Misses         43       44       +1     
Impacted Files Coverage Δ
common/src/tsv_utils/common/fieldlist.d 99.87% <ø> (ø)
common/src/tsv_utils/common/utils.d 100.00% <ø> (ø)
tsv-filter/src/tsv_utils/tsv-filter.d 100.00% <ø> (ø)
tsv-join/src/tsv_utils/tsv-join.d 100.00% <ø> (ø)
tsv-sample/src/tsv_utils/tsv-sample.d 99.43% <ø> (ø)
tsv-split/src/tsv_utils/tsv-split.d 98.45% <ø> (ø)
tsv-summarize/src/tsv_utils/tsv-summarize.d 98.26% <ø> (ø)
tsv-uniq/src/tsv_utils/tsv-uniq.d 100.00% <ø> (ø)
tsv-select/src/tsv_utils/tsv-select.d 100.00% <100.00%> (ø)