Sample Header Ad - 728x90

How to extract columns in which their name containing the word "chronic" from CSV file

2 votes
7 answers
746 views
I have a big csv file ( around 1000 columns ) and I want to extract to a new file only columns that contain the word "chronic" in their header name. How can I do that ? For example if I have:
gender,chronic_disease1,chronic_disease2
male,2008,2009
The desired output is:
chronic_disease1,chronic_disease2
2008,2009
Note: the column/field separators is comma ",". if there was no chronic match then no output at all.
Asked by Solomon123 (131 rep)
Mar 25, 2023, 11:58 AM
Last activity: Apr 10, 2023, 12:20 AM