Help reformatting input file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help reformatting input file
# 1  
Old 09-07-2015
Help reformatting input file

Hi,
I have an input file that looks like this (columns are tab delimited:
HTML Code:
Data000005-RA    GO:0003735    GO:0005840    GO:0006412                
Data000005-RA    GO:0003735                                    
Data000009-RA    GO:0003735    GO:0005622    GO:0005840    GO:0006412            
Data000011-RA    GO:0015232    GO:0015886    GO:0016020    GO:0017004            
Data000012-RA    GO:0005524                        
Data000012-RA    GO:0015991    GO:0016820    GO:0005524                
Data000040-RA    GO:0004129    GO:0005506    GO:0009055    GO:0009060    GO:0016021    GO:0020037    GO:0055114
This need to be converted into a two column file and expected output is:
HTML Code:
Data000005-RA    GO:0003735
Data000005-RA    GO:0005840    
Data000005-RA    GO:0006412                
Data000005-RA    GO:0003735                                    
Data000009-RA    GO:0003735
Data000009-RA    GO:0005622
Data000009-RA    GO:0005840
Data000009-RA    GO:0006412            
Data000011-RA    GO:0015232    
Data000011-RA    GO:0015886
Data000011-RA    GO:0016020
Data000011-RA    GO:0017004            
Data000012-RA    GO:0005524                        
Data000012-RA    GO:0015991
Data000012-RA    GO:0016820
Data000012-RA    GO:0005524                
Data000040-RA    GO:0004129
Data000040-RA    GO:0005506
Data000040-RA    GO:0009055
Data000040-RA    GO:0009060
Data000040-RA    GO:0016021
Data000040-RA    GO:0020037
Data000040-RA    GO:0055114
Thanks for your help.
# 2  
Old 09-07-2015
Hello Fahmida,

Following may help you in same.
Code:
awk '{for(i=2;i<=NF;i++){print $1 OFS $i}}'  OFS="\t" Input_file

Output will be as follows.
Code:
Data000005-RA   GO:0003735
Data000005-RA   GO:0005840
Data000005-RA   GO:0006412
Data000005-RA   GO:0003735
Data000009-RA   GO:0003735
Data000009-RA   GO:0005622
Data000009-RA   GO:0005840
Data000009-RA   GO:0006412
Data000011-RA   GO:0015232
Data000011-RA   GO:0015886
Data000011-RA   GO:0016020
Data000011-RA   GO:0017004
Data000012-RA   GO:0005524
Data000012-RA   GO:0015991
Data000012-RA   GO:0016820
Data000012-RA   GO:0005524
Data000040-RA   GO:0004129
Data000040-RA   GO:0005506
Data000040-RA   GO:0009055
Data000040-RA   GO:0009060
Data000040-RA   GO:0016021
Data000040-RA   GO:0020037
Data000040-RA   GO:0055114

Thanks,
R. Singh

Last edited by RavinderSingh13; 09-07-2015 at 02:02 AM..
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 09-07-2015
Thanks Ravinder!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reformatting of an output file

Hi, i've got the following output file: 170724_1600 | SYSTEM | 449 | 282 | 167 | 62 170724_1600 | CCS_SCP_DATA | 200 | 88 | 112 | 44 170724_1600 | CCS_SCP_SUBS_I | 2001 | 1751 | 250 | 87 170724_1600 | UIS_CDR_INDEX | 2001 | 1 | 2000 | 0 170724_1600 | LCP_INDEX | 200 | 5 | 195 | 2... (4 Replies)
Discussion started by: nms
4 Replies

2. UNIX for Dummies Questions & Answers

Need help in reformatting the input

Hi i want to print line which is mentioned as below 615213:1;20150725;20250722;0|11;20150831;20150831;100|14;20150725;20160723;2 in below format. ' 615213: 1;20150725;20250722;0 615213: 11;20150831;20150831;100 615213: 14;20150725;20160723;2 please help me and suggest me how to... (9 Replies)
Discussion started by: scriptor
9 Replies

3. Shell Programming and Scripting

Reformatting a file for biological purpose

Dear ALL, I would really appreciate if you could help me in reformatting a file in this way: The file refers to a list of genetic coordinates, each lines has a score value and the associated chromosome is listed in the line starting with chrom . If more coordinates are found, the start... (2 Replies)
Discussion started by: paolo.kunder
2 Replies

4. Shell Programming and Scripting

Reformatting single column text file starting new line when finding particular string

Hi, I have a single colum file and I need to reformat the file so that it creates a new line every time it come to an IP address and the following lines are corresponding rows until it comes to the next IP address. I want to turn this 172.xx.xx.xx gwpusprdrp02_pv seinwnprd03... (7 Replies)
Discussion started by: kieranfoley
7 Replies

5. Shell Programming and Scripting

Stripping characters from a file and reformatting according to another one

Dear experts, my problem is pretty tricky. I want to change a file (see attached input.txt), according to another file (help.txt). The output that is desired is in output.txt. The example is attached. Note that -dashes should not be treated specially, they are considered normal characters,... (2 Replies)
Discussion started by: TheTransporter
2 Replies

6. Shell Programming and Scripting

Help for reformatting text file and creating new format

Hi all, I have an input file like 1,date,company,, 1,date,comapny,, 2,000,,,567,ACT,00,,,,KKG,M1,D45,,67J,+4500000000 2,000,,,567,ACT,00,,,,KKG,M6,D49,,56J,+6000 2,000,,,567,ACT,00,,7,,KKG,M3,D58,,68h,-70000 2,000,,,567,ACT,00,,,,KKG,M9,D95,,34m,0.00 3,total what i require is 1.I... (2 Replies)
Discussion started by: selvankj
2 Replies

7. Shell Programming and Scripting

reformatting xml file, sed or awk I think (possibly perl)

I have some xml files that cannot be read using a standard parser, or I am using the wrong parser. The issues seems to be spaces in some of the tags. Here is a sample,<UgUn 2 > <Un> -0.426753 </Un> </UgUn>The parser isn't able to find the number 2, so that information is lost, etc. It seems... (16 Replies)
Discussion started by: LMHmedchem
16 Replies

8. Shell Programming and Scripting

awk multiple file reformatting

I hopefully have a simple request - I need to process multiple files reformatting the output based on tags at the beginning of each line. So the data for the new 3 lines of the output file are in the HDR line and then the details are in the DTL tagged lines. for ifile in $indir do echo... (1 Reply)
Discussion started by: jason_v_brown
1 Replies

9. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

10. UNIX for Dummies Questions & Answers

Reformatting file

Hi, How can I reformat a file (text file) using unix command. This file was FTP'd from Mainframe and contains some garbage character at the end of each line. Each line contains special characters '<soh>' at the end which should have been spaces when I view it in emacs or nedit. I couldnt do find... (2 Replies)
Discussion started by: mrjunsy
2 Replies
Login or Register to Ask a Question