How to order data based on missing values?
I have a file which looks like this.
Code:
con1 BC1a:25 BC1b:25 BC2a:2 BC2b:20 BC3a:5 BC3b:56 My result should look something like this Code:
con1 BC1a:25 BC1b:25 BC2a:2 BC2b:20 BC3a:5 BC3b:56 My actual file has many thousands of rows and 150 columns. Any ideas of how to do this? Thanks in advance. |
not easy... but doable.
I'd do it in perl - the associative hash tables would do it (the BC1a labels used as subscript). You start with an array - containing all the labels you will be using. Then create a reference hash table that has values for each of the labels (the "-"). in a loop for each line, initialize a new hash table with the reference table. for each token on the line (you do have to split the token at the ":") replace the new hash table entry with the string based on the BCxx label that is in the token list. Last, output the new hash table based on the array (in the proper order) containing the labels. You could do it with python, but I'm not that familiar with python. Can't give you a sample code right now - have to deal with some cats... Maybe tomorrow though. |
My attempt at a bash solution.
Code:
!/bin/bash Code:
con1 BC1a:25 BC1b:25 BC2a:2 BC2b:20 BC3a:5 BC3b:56 |
All times are GMT -5. The time now is 12:23 PM. |