Hi All,
I have two tables of data, one contains 9 columns and another has 7 columns,
both the tables has 3 column common, now what i am trying to do is to merge the two tables in one using hash.
I used the first tables as the hash and made 4th column as the key and rest 5,6,7,8,9 as the values and now i read the another table and if the values existes then print the information from both the tables.
here is my code -
#!/usr/bin/perl
-
use strict;
-
use warnings;
-
my (%hashname,$cnum,$ctotal,$count,$number,$pdb,$crossangle,$resname,$respos,$resdist,@temp);
-
open(SP,"<packing_cluster.dat") or die "Could not open $!";
-
while(<SP>)
-
{
-
my $line1 = $_;chomp $line1;
-
@temp = split (/\s/,$line1);
-
$cnum = $temp[1];
-
$ctotal = $temp[2];
-
$count = $temp[3];
-
$number = $temp[4];
-
$pdb = $temp[5];
-
$crossangle = $temp[6];
-
$resname = $temp[7];
-
$respos = $temp[8];
-
$resdist = $temp[9];
-
$hashname{$number} = ($pdb,$crossangle,$resname,$respos,$resdist);
-
}
-
close(SP);
-
my $cnt =0;
-
#while (($number,$pdb) = each (%hashname))
-
#{
-
# print "$number => $pdb\n";
-
# $cnt +=1;
-
#}
-
open(CG,"rmsd_cluster.dat") or die "Check relevant file";
-
while(<CG>)
-
{
-
my $line2 = $_; chomp $line2;
-
my @gsp = split(/\s/,$line2);
-
if (exists $hashname{$gsp[5]})
-
{
-
print "$gsp[2]\t$gsp[3]\t$gsp[4]\t$gsp[5]\t$hashname{$gsp[5]}\t$gsp[7]\t$crossangle\n";
-
$cnt +=1;
-
}
-
}
-
#close(WRITE1);
-
print "$cnt\n";
-
the problem is i am not able to print the table in desired way.
Any help will be appreciated.
Thanks
Kumar
3 4014 eWish 971
Recognized Expert Contributor
May we please see some sample data?
--Kevin
KevinADC 4,059
Recognized Expert Specialist
at a minimum this line looks wrong: - $hashname{$number} = ($pdb,$crossangle,$resname,$respos,$resdist);
you want to use square brackets to assign an array to a hash key: - $hashname{$number} = [$pdb,$crossangle,$resname,$respos,$resdist];
thats because its actually a reference to an array.
hi the sample data looks like
table 1
cnum ctotal count number pdb crossangle resname respos resdist
2 148 1 5265 xxx 25.3 ALA 25 6.6
2 148 2 4414 yyy 13.6 GLY 32 5.1
table 2
cnum ctotal count number pdb rmsd
2 148 1 5265 xxx 2.5
2 148 2 4414 yyy 1.3
now i am tying to merge the two table so that i can have one comple table rather than 2. I am trying to make number(table1) as key and rest column as values(table 1) and now matching the number (in table 2) and then merging the tables.
thanks
kumar
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Frederic |
last post by:
Hi,
I've a problem, I've a select tag with n items. It is build from a db
request with an id, a code and a label. I need to get the id and the
code when the user select a label. How can I do that without doing an
other request to database ? Can I use array as value attribute of option
tag ?
Thanks
|
by: VBNovice05 |
last post by:
I am creating a hash check for an item on a classified network. The
FIPS has to be enabled and everytime my software runs I get this error
: "System.InvalidOperationException: This implementation is not part of
the Windows Platform FIPS validated cryptographic algorithms.
" I used System.Security.Cryptography.MD5CryptoServiceProvider.
...
|
by: yp.yean |
last post by:
Hi,
I created a custom control, and encountered a dirty property value
persistence problem.
I created a property with a custom class type, call SQLSettings which
holds the SQL connection parameters, the class as follows:
public sealed class SQLSettings
{
private string serverName;
|
by: imrantbd |
last post by:
This is my first problem.Please help me.
I have the following code:
<head>
<script language="JavaScript">
function addSrcToDestList() {
destList1 = window.document.forms.destList;
srcList = window.document.forms.srcList;
|
by: imrantbd |
last post by:
I need array type name like "destList" must use for my destlist select box,not a single name.Or need a solution to capture multiple value of "destList" select box and send all selected value in php page.The multiple select value then insert in database added by comma.The following is my code:
Form Page:form.php
<head>
<script...
| |
by: boyindie86 |
last post by:
Hi
I have been dabbling with a password salted hashing scheme, so to encrpyt my passwords in my users table in mySQL
the code i have done is vb.net with asp
The code seems to run fine until I try to execute the query
and it throws the following exception at the line
|
by: ahmurad |
last post by:
Dear all,
I am fresh php programmer. I've spent much time to solve a checkbox related null value submission problem in php platform.
I want to submit 4 checkbox value. if I checked all the checkbox, all the checked value is submitted properly. if checked any checkbox , the corresponding checkbox value is submitted properly.
But I need to...
|
by: permander kumar |
last post by:
hi
plz help me,
i have a code in which two multiple selection dropdown list. in first list if I am select single value the data are fetch in second table on button click. but the problem is in first dropdown list the second field is also select after the page submit.
the code is
<?php
include("connect.php");
?>
<html><body>
|
by: metaphysics |
last post by:
I am using a jQuery script called LocalScroll, and I have a quick problem that needs fixing. The demo for the script is here: jQuery.LocalScroll - Regular Demo, and the documentation is here: Ariel Flesler: jQuery.LocalScroll. The Local Scroll script uses the toScroll and jQuery scripts to function.
I don't really understand what "hash" means,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |