I have a csv like this,
type,name,ad1,pin,ph
"A","aaaaa","23 rd.","45789","4578954"
"F","bbbbb","23 rd.","84789","4578954"
"D","ccccc","34 rd.","45646","7845663"
this needs to be formatted to a plain text file like this.
type
name
ad1, PIN-pin
PH: ph
So the final output would be like this.
A
aaaaa
23 rd., PIN- 45789,
PH: 4578954
F
bbbbb
23 rd. PIN-84789
PH:4578954
D
ccccc
34 rd., PIN-45646
PH: 7845663
Is it possible to achieve this in csvkit.
You can use miller (https://github.com/johnkerl/miller/releases/tag/5.4.0):
mlr --c2x --ops "\t" put '$1=$type;$2=$name;$3=($ad1 . ", PIN-" . $pin);$4=("PH: " . $ph)' \
then cut -r -f "^[0-9]" input.csv | \
cut -f2
to have
A
aaaaa
23 rd., PIN-45789
PH: 4578954
F
bbbbb
23 rd., PIN-84789
PH: 4578954
D
ccccc
34 rd., PIN-45646
PH: 7845663
Some notes:
--c2x
to convert csv to XTAB (http://johnkerl.org/miller/doc/file-formats.html#XTAB:_Vertical_tabular);--ops
to set tab as pair separatorput
to set the field the way you want (I create 4 new fields, named 1, 2, 3 and 4)cut
(before the pipe) to delete all fields except 1, 2, 3 and 4cut
delete field names