dsvfields - given stdin dsv, print fields by name
Essentially this can transform dsv input to strip down to something else This makes it easy to select fields, because you can do it by name instead of by position.
dsvfields [OPTIONS]..
-F don't output fields line -c comment the fields line -f string fields, separated by non word chars (limitation) -h help -v version
For these examples our data.dsv is:
# this is a table description, it is a comment # the next line however, will be deemed to be the fields line # fields = 'name:age:occupation' leo : 34 : developer jane : 21 : chemist marco : 45 : vagrant
Let's output age, and occupation cat data.dsv | dsvfields -f 'age occupation'
Just age and then name, no fields line cat data.dsv | dsvfields -f 'age name'
Same but and sort by age.. cat data.dsv | dsvfields -F -f 'age name' | sort
Same but sort by name, just flip the order.. cat data.dsv | dsvfields -F -f 'name age' | sort
This will only work with dsv streams that have field names
The first line must have the field names the field separator in that line must be the same as in the data
Example correct field name lines with corresponding data line
# fields = 'age name' leo 34 # fields = "age:name" leo:34 # FIELDS=age:name leo:34 age name leo 34 age,name leo,34 age:name leo:34
Leo Charre leocharre at cpan dot org
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License".
This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the "GNU General Public License" for more details.
To install dsvfields, copy and paste the appropriate command in to your terminal.
cpanm
cpanm dsvfields
CPAN shell
perl -MCPAN -e shell install dsvfields
For more information on module installation, please visit the detailed CPAN module installation guide.