Joining files in a complex way


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Joining files in a complex way
# 15  
Old 03-16-2010
Quote:
Originally Posted by stateperl
I'm afraid I couldn't get 5th column?
I think these symbols "" messing up a bit. Could you please assume input with out "
...
You don't have the 5th string in your printf statement near the end of the program.
The line # 65 in the Perl program of my earlier post is the one missing.
The printf function at line 60 has the format masks for 6 strings, and those strings are typed, one per line, from line 61 through 66.

tyler_durden

Last edited by durden_tyler; 03-16-2010 at 02:48 PM..
# 16  
Old 03-17-2010
a smallbug

yep that worked well. Thank u very much.

I think there is a small bug. when ever the script finds same IDs in input 1 (ex:S1) and input2 (ex:S1) , the output is fine. But if the input1 (ex: S1) doesn't have the same ID in input 2 (ex:S100) the output shouldn't include any thing from input1 or 2 [So the bug is that output is printing all unmatched IDs ]

Hope you don't feel bad about dragging this post a bit.

input1
Code:
"aphab"    "S1"  "S2"
"a"    "T/T"    "A/A"
"b"    "A/G"   "A/B"
"c"    "T/T"    "A/F"
"d"    "G/G"   "D/D"
"e"    "A/G"   "W/W"

input2
Code:
"ID"    "Label"    "log"
"S1"    "xxx"    2.8
"S1"    "xxx"    3
"S1"    "xxx"    4
"S100"    "yyy"    6.8
"S100"    "yyy"    7
"S100"    "yyy"    7.4
"S100"    "yyy"    8

output should be with only S1 [ no S2 or S100 values at all.]
Code:
"ID"        "Label"     "StYPE"     "Ntype"     "Stype_No"  "log"
"S1"        "xxx"       "T/T"       1           2           2.8
"S1"        "xxx"       "A/G"       2           2           3
"S1"        "xxx"       "G/G"         3          1           4

thanx

Last edited by stateperl; 03-17-2010 at 01:34 PM..
# 17  
Old 03-17-2010
Quote:
Originally Posted by stateperl
... But if the input1 (ex: S1) doesn't have the same ID in input 2 (ex:S100) the output shouldn't include any thing from input1 or 2 ...
This can be accomplished by a minor change in the 2nd part of the script. If you go through the script carefully and understand it thoroughly, then you should be able to fix it.
I'll leave it for you as an exercise.

Quote:
Originally Posted by stateperl
...
I think there is a small bug. ... [So the bug is that output is printing all unmatched IDs ]
...
And I think this is a new requirement.
The course of action in case of mismatched IDs was never mentioned in any of your previous posts.
If the requirements are clear, and despite that, the program doesn't print correct output, then it may be classified as a bug.
But if the requirements are not clear, then the program is bound to take unpredictable/default courses of action that you may not agree with.
This can be easily remedied by being very clear as to what you want, from square one.

tyler_durden
# 18  
Old 03-18-2010
ehmm!

------------------------------

Last edited by stateperl; 03-24-2010 at 12:31 AM..
# 19  
Old 03-19-2010
problems

------------------------------------

Last edited by stateperl; 03-24-2010 at 12:30 AM..
# 20  
Old 03-24-2010
Hey Tyler could you please explain the last code you have written. So that I could do my own modifications instead of asking you. Please. Sorry for bothering you.

Last edited by stateperl; 03-24-2010 at 12:52 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help me in joining two files

I have two files with the below contents : sampleoutput3.txt 20150202;hostname1 20150223;hostname2 20150716;hostname3 sampleoutput1.txt hostname;packages_out_of_date;errata_out_of_date; hostname1;11;0; hostnamea;12;0; hostnameb;11;0; hostnamec;95;38; hostnamed;440;358;... (2 Replies)
Discussion started by: rahul2662
2 Replies

2. Shell Programming and Scripting

Joining 2 Files

File "A" (column names: Nickname Number GB) Nickname Number GB PROD_DB0034 100A 16 ASMIL1B_DATA_003 100B 16 PSPROD_0000 1014 36 PSPROD_0001 100D 223 ..... File "B" (column names: TYPE DEVICE NUMBER SIZE) TYPE DEVICE NUMBER SIZE 1750500 hdisk2 100A 16384 1750500 hdisk3 ... (4 Replies)
Discussion started by: Daniel Gate
4 Replies

3. Shell Programming and Scripting

Help with joining files and adding headers to files

Hi, I have about 20 tab delimited text files that have non sequential numbering such as: UCD2.summary.txt UCD45.summary.txt UCD56.summery.txt The first column of each file has the same number of lines and content. The next 2 column have data points: i.e UCD2.summary.txt: a 8.9 ... (8 Replies)
Discussion started by: rrdavis
8 Replies

4. Shell Programming and Scripting

Joining two files into one

Hi experts, I'm quite newbie here!! I have two seperate files. Contents of file like below File 1: 6213019212001 8063737 File:2 15703784 I want to join these two files into one where content will be File 3: 6213019212001 8063737 15703784 Regards, Ray Seilden (1 Reply)
Discussion started by: RayanS
1 Replies

5. UNIX for Dummies Questions & Answers

Joining two files

I have two comma separated files. I want to join those filesa nd put the result in separate file. smaple data are: file1: A1,1,100 A2,1,200 B1,2,100 B2,2,200 file2 1,50 1,25 1,25 1,100 1,100 2,50 2,50 (10 Replies)
Discussion started by: pandeesh
10 Replies

6. Shell Programming and Scripting

Joining Three Files

Hi guys, I have three files which needs to be joined to a single file. File 1: Col a, Col b, Col c File 2: Col 1a, Col 1b File 3: Col 2a, Col 2b Output: Col 1a, Col 2a, Col a, Col b, Col c. All the files are comma delimited. I need to join Col b with Col 1b and need to... (17 Replies)
Discussion started by: mac4rfree
17 Replies

7. Shell Programming and Scripting

joining two or more files

i have three files file a has contents 123 234 238 file b has contents 189 567 567 and file c has contents qwe ert ery (1 Reply)
Discussion started by: tomjones
1 Replies

8. Shell Programming and Scripting

Help with joining two files

Greetings, all. I've got a project that requires I join two data files together, then do some processing and output. Everything must be done in a shell script, using standard unix tools. The files look like the following: File_1 Layout: Acct#,Subacct#,Descrip Sample: ... (3 Replies)
Discussion started by: rjlohman
3 Replies

9. UNIX for Dummies Questions & Answers

joining 2 files

Hi, I have two files that I need to find difference between. Do I use diff or join? If join, how do I use it? thanks, webtekie (1 Reply)
Discussion started by: webtekie
1 Replies
Login or Register to Ask a Question