BurntSushi / xsv

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

Looking for a solution to clear column data but not the headers #343

Open karudonaldson opened 3 months ago

karudonaldson commented 3 months ago

We have a good number of columns perhaps 100, there are about 30 that require clearing, therefore when the csv is imported, those cleared down columns will have no data in them.

I was thinking gawk, or sed to find and replace "data" with "null" or something to that affect but we may not know all of the possible values, therefore a straight clear down of column data less the header would be more appropriate.

Any ideas would be greatly appreciated?

LafCorentin commented 1 week ago

@karudonaldson, is that what you're thinking to ?

col1,col2,col3
foo,bar,
,bah,lorem
ipsum, foo,bar

then something like xsv --clear col1,col2 file.csv

to get

col1,col2,col3
,,
,,lorem
,,bar