Use the 1st line of file_2 as an example, "fcust_034_60 2"
==> f2[$1]=$2
It looks to me, the code only put the 2nd field, which is the number 2,
into the array's position $1, not the entire current line goes in there.
We associate the value of the first field (this is the key, the pseudo-index) with the value of the second one
(the value, the array element).
This is actually the entire line (because in this case file_2 contains only two fields).
Note that what you see in the output is the content of the entire line from file_1
and only the second column from file_2:
awk's arrays are associative: consider them key-value pairs.
"Array position $1" actually means that the value of the second field $2
is associated with the key - the value of the first field:
2. how f2's element being retrieved by the code
==> f2[$2]?
If it had just put a field in the 1st step,
how could the code use "fcust_034_60" now read in from file_1 to search against the array f2?
To me, "fcust_034_60" is even not in f2.
And in the previous step, seems to me, the code "f2[$1]=$2", just put $2 from the line in the $1 position of f2. How come when retrieved, it is from the position $2 of f2?
The value is retrieved by comparing the value of the second field from file_1
with the keys present in the associative array f2
(in this case: cust_034_60 and cust_406_4).
Hi Experts,
I need your timely help. I have a problem with merging two files. Here my situation :
Here I have to compare first three fields from FILE1 with FILE2. If they are equal, I have to append the remaining values from FILE2 with FILE1 to create the output.
FILE1:
Class ... (3 Replies)
I have two files with ids and email addresses. File 2 cotains a subset of the records in file 1. The key field is the first field containing the id.
file 1:
123|myadr@abc.com
456|myadr2@abc.com
789|myadr3@abc.com
file 2:
456|adr456@xyz.com
Where the record appears in the second... (3 Replies)
Hi,
i want to compare two files by one field say $3 in file1 needs to compare with $2 in file2.
sample file1 - reqd_charge_code
2263881188,24570896,439
2263881964,24339077,439
2263883220,22619162,228
2263884224,24631840,442
2263884246,22612161,442
sample file2 - rg_j
... (2 Replies)
Hi all,
I searched the forum and tried to learn from the similar posts. However, I am new and I need to get help on this. I hope an expert kindly help me to sort this out.
I need to compare field 1 and 2 of the first file with the same fields of the second file and if both fields matches... (9 Replies)
I've 2 files. Need to compare File1.Field1,File1.Field2 with File2.Field1,File2.Field2. If matches then create a new file.
File1
10 A|ADB|967143.24|1006101.5
3E HK|DHB|24294.76|242513.89
ABN ACU|ADB|22104.69|51647.14
ABN BU|DBA|39137.14|109128.38
ABN|ADB|64466.89|167936.55
ABOC... (2 Replies)
I am newbie to unix and would please like some help to solve the task below
I have two files, file_a.text and file_b.text that I want to evaluate.
file_a.text
1698.74
1711.88
6576.25
899.41
3205.63
4187.98
697.35
1551.83 ... (3 Replies)
Hi
I have 2 files as below
File 1
Chr Start End
chr1 120 130
chr1 140 150
chr2 130 140
File2
Chr Start End Value
chr1 121 128 ABC
chr1 144 149 XYZ
chr2 120 129 PQR
I would like to compare these files using awk; specifically if column 1 of file1 is equal to column 1 of file2... (7 Replies)
Hi All,
I am looking for an awk script to do the following
Join the fields together only if the first 4 fields are same.
Can it be done with join function in awk??
a,b,c,d,8,,,
a,b,c,d,,7,,
a,b,c,d,,,9,
a,b,p,e,8,,,
a.b,p,e,,9,,
a,b,p,z,,,,9
a,b,p,z,,8,,
desired output:
... (1 Reply)
I want to compare File1 and File2 (Separated by spaces) using four fields (Column 1,2,4,5).
Logic: If column 1 and 2 of File1 and File2 match exactly and if the File2 has the same characters as any of the characters present in column 4 and 5 of file1 then those lines of file1 and file2 are... (1 Reply)
Dear All,
I want to compare File1 and File2 (Separated by spaces) using four fields (Column 1,2,4,5).
Logic: If column 1 and 2 of File1 and File2 match exactly and if the File2 has the same characters as any of the characters present in column 4 and 5 of file1 then those lines of file1 and file2... (6 Replies)
Discussion started by: NamS
6 Replies
LEARN ABOUT DEBIAN
tangram::type::array::fromone
Tangram::Type::Array::FromOne(3pm) User Contributed Perl Documentation Tangram::Type::Array::FromOne(3pm)NAME
Tangram::Type::Array::FromOne - map Perl arrays using a foreign key
SYNOPSIS
use Tangram;
# or
use Tangram::Core;
use Tangram::Type::Array::FromOne;
$schema = Tangram::Schema->new(
classes => { Agenda => { fields => {
iarray =>
{
# long form
entries =>
{
class => 'Entry',
coll => 'agenda',
},
# or (short form)
entries => 'Entry',
}
DESCRIPTION
This class maps references to a Perl array in an intrusive fashion. The persistent fields are grouped in a hash under the "iarray" key in
the field hash.
The array may contain only objects of persistent classes. These classes must have a common persistent base class.
Tangram uses two columns on the element's table to store:
* the id of the object containing the collection
* the position of the element in the collection
CAUTION: the same object may not be an element of the same collection, in two different objects. This mapping may be used only for one-to-
many relationships.
The field names are passed in a hash that associates a field name with a field descriptor. The field descriptor may be either a hash or a
string. The hash uses the following fields:
* class
* aggreg
* back
* coll
* slot
* deep_update
Mandatory field "class" specifies the class of the elements.
Optional field "aggreg" specifies that the elements of the collection must be removed (erased) from persistent storage along with the con-
taining object. The default is not to aggregate.
Optional field "back" sets the name of a field that is inserted in the elements. That field acts as a demand-loaded, read-only reference to
the object containing the collection.
Optional field "coll" sets the name the column containing the id of the containing object. This defaults to 'C_m', where 'C' is the class
of the containing object, and 'm' is the field name.
Optional field "slot" sets the name the column containing the id of the containing object. This defaults to 'C_m_slot', where 'C' is the
class of the containing object, and 'm' is the field name.
The "C" in C_m and C_m_slot are passed through the schema normalisation function before being combined into a column name.
Optional field "deep_update" specificies that all elements have to be updated automatically when "update" is called on the collection
object. Automatic update ensures consisitency between the Perl representation and the DBMS state, but degrades update performance so use it
with caution. The default is not to do automatic updates.
If the descriptor is a string, it is interpreted as the name of the element's class. This is equivalent to specifying only the "class"
field in the hash variant.
perl v5.8.8 2006-03-29 Tangram::Type::Array::FromOne(3pm)