BurntSushi / xsv

A fast CSV command line toolkit written in Rust.
The Unlicense
10.23k stars 317 forks source link

Split a column #311

Open 2803media opened 1 year ago

2803media commented 1 year ago

Hi I have the following awk command and I try to convert it to xsv but failed to split a string from a column with the tool

awk -F';' -vFPAT='([^;]*)|("[^"]*")' 'FNR==1{print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13","$14","$15","$16","$17","$18","$19","$20","$21","$22","$23","$24","$25","$26","$27","$28",""DEPET" } FNR>1{gsub(/,|"/, "", $23); if (substr ($13, 1,2) == "97" || substr ($13, 1,2) == "98") a = substr ($13, 1,3); else a = substr ($13, 1,2); print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13","$14","$15","$16","$17","$18","$19","$20","$21","$22","$23","$24","$25","$26","$27","$28","'a' }' test.csv

Do you know if it's possible to do a thing like that with xsv?

Thanks