How would one remove the 3rd column for example from a csv file directly from the command line of the Mac terminal. I understand
cut -d',' -f3 data.csv
extracts the column info out directly into the terminal, but I want the 3rd column to be entirely removed from the dataset. How can I do this via the terminal?
Try
cut -d',' -f1-2,4- data.csv
All the examples seem a bit tricky if trying to delete multiple fields or if you want to see only several columns. As such I simply show only the columns I want. So if I only want to get columns 1,2 and 5 I'd do this:
cut -d, -f 1,2,5 hugeData.csv
NB: -d sets whatever the separator is in the file. In the example above it is a comma ,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With