Skip to content

tpkn/cutc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

It cuts, duplicates and rearranges fields in a csv file.

Usage

cutc [ -options ] < <file.csv>

Options

-d, --delimiter    Fields delimiter (default: comma)
-f, --fields       Fields indexes to cut (starting from 1; could be a ranges; order matters)
-h, --header       Skip csv header
-t, --trim         Remove spaces and tabs from the beginnig and end of the each field
--help             Help
--version          Version

Examples

Cut columns 1 and 4

cutc -f 1,4 < input.csv

Cut columns 1, 2 and 3 and skip header row

cutc -f 1,2,3 -h < input.csv

Cut columns 1, 4 and 7, but print them in a specific order - 4,1,7

cutc -f 4,1,7 < input.csv

Cut and gzip

cutc -f 1,4,7 < input.csv | gzip -c > output.csv.gz

Cut columns of gzipped csv into a separate files

gunzip -c input.csv.gz | \
tee >(cutc -f 1 > output_1.csv) \
    >(cutc -f 5 > output_5.csv) \
    >(cutc -f 7 > output_7.csv) > /dev/null

Duplicate fields 1 and 7 multiple times

cutc -f 4,1,1,7,7 < input.csv

Slice and dice... to get fields: 1,2,3,62,63,64,1,2,3,4,5,99,100,95

cutc -f 1,2,3,62-64,-5,99-,95 < input.csv

About

It cuts, duplicates and rearranges fields in a csv/tsv files.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages