How to concatenate strings under multiple headings in .csv file into a new file?
Hi guys,
I have multiple .csv files with multiple columns/headings, set up essentially like this (obviously more info in the real thing) Gene Location Ref Var Coverage Function DMD chrX.... A G 198 exonic SCN4A chr17.... T C 111 splicing and so on... How could I concatenate selected columns into an output file with strings seperated with a comma? eg DMD,A,G,exonic (similar to what you can do in excel). I would like to be able to do this for multiple files in a directory. It would be preferable if all the outputs could be compiled into one file as I'll use this for something else later. The current protocol in our team is to concatenate each file individually with an excel macro and copy into a file, and it takes a very long time. Thanks very much!! |
How about awk?
Code:
awk -F' ' '{print $1,$3,$4,$5}' OFS="," file.csv Code:
cat file.csv | tr ' ' ',' | cut -d',' -f1,3,4,5 |
thanks
Thanks, that was good!
|
Please mark as SOLVED once you have a solution.
|
All times are GMT -5. The time now is 08:56 AM. |