C
C
cyberlain2021-03-18 10:22:41
linux
cyberlain, 2021-03-18 10:22:41

How to delete a column (columns) by their location (number) in a csv file?

There is a csv file with 12 fields, not commas but a semicolon as separators. There was a task to delete 2-3 and from 5-10th columns. Googled the solution cut -d, -f2-3 --complement out.csv > edited.csv; But in it, by default, the breakdown is by commas and not by semicolons. What can you advise? Is there a simple and short terminal command in bash that removes the required columns?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kiberlain, 2021-03-18
@cyberlain

Thanks everyone, I found the solution
cut -d ';' -f 2-3.5-10 in.csv > out.csv;

A
Alexey Dmitriev, 2021-03-18
@SignFinder

The first link on request "cut custom delimiter" - https ://unix.stackexchange.com/questions/556891/ca...
return back.

R
Ruslan Fedoseev, 2021-03-18
@martin74ua

info textutils
man sed
man awk
man perl
You can assemble the necessary command from elementary bricks... No one will tell you a ready-made solution right away, because the data structure is not visible. But you can do everything) I translated the command from the syntax of the cat to the syntax of the jun)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question