Sponsored Content
Top Forums Shell Programming and Scripting Joining files in a complex way Post 302401380 by stateperl on Friday 5th of March 2010 09:58:31 PM
Old 03-05-2010
@Tyler:::::Thank you for pointing it out. I edited the post above to explain the question better. Please take a look.
@binlib:::Amazing and clear code. Thanks alot! but a small bug in it. It's giving unnecessary values at the end (bold)
And one more thing. For suppose if I have multiple input2 files (with same IDs but different Stypes and log values ) and a single input1, is this code works the same??? if not could you please suggest me..
####
I tested with multiple input2files, its working but giving 2 separate outputs (outpu1 and output2). What I need is a single output (common output that adds all Ntypes together)

thanx
Pearl.

output
Code:
oem@mintibm ~/Desktop/Temp_SNP $ cat output.txt 
"ID"	"Label"	"StYPE"	"Ntype"	"Stype_No"	"log"
"S1"	"xxx"	"A/A"	1	6	2.8
"S1"	"xxx"	"A/G"	2	2	3
"S1"	"xxx"	"G/G"	3	1	4
"S2"	"yyy"	"A/A"	1	1	6.8
"S2"	"yyy"	"A/G"	2	2	7
"S2"	"yyy"	"G/G"	3	6	7.4
"S2"	"yyy"	"NULL"	"null"	"null"	8
"S3"	"zzz"	"A/A"	1	3	12
"S3"	"zzz"	"A/G"	2	3	14
"S3"	"zzz"	"G/G"	3	3	16
"S3"	"zzz"	"NULL"	"null"	"null"	18
"S3"	"zzz"	"NULL"	"null"	"null"	20
		"A/A"	1	


Last edited by stateperl; 03-05-2010 at 11:20 PM..
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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 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

7. 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

8. 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

9. 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
Config::Model::Loader(3pm)				User Contributed Perl Documentation				Config::Model::Loader(3pm)

NAME
Config::Model::Loader - Load serialized data into config tree VERSION
version 2.021 SYNOPSIS
use Config::Model; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init($WARN); # define configuration tree object my $model = Config::Model->new; $model->create_config_class( name => "Foo", element => [ [qw/foo bar/] => { type => 'leaf', value_type => 'string' }, ] ); $model ->create_config_class ( name => "MyClass", element => [ [qw/foo bar/] => { type => 'leaf', value_type => 'string' }, hash_of_nodes => { type => 'hash', # hash id index_type => 'string', cargo => { type => 'node', config_class_name => 'Foo' }, }, [qw/lista listb/] => { type => 'list', cargo => {type => 'leaf', value_type => 'string' } }, ], ) ; my $inst = $model->instance(root_class_name => 'MyClass' ); my $root = $inst->config_root ; # put data my $step = 'foo=FOO hash_of_nodes:fr foo=bonjour - hash_of_nodes:en foo=hello ! lista=foo,bar lista:2=baz listb:0=foo listb:1=baz'; $root->load( step => $step ); print $root->describe," " ; # name value type comment # foo FOO string # bar [undef] string # hash_of_nodes <Foo> node hash keys: "en" "fr" # lista foo,bar,baz list # listb foo,baz list # delete some data $root->load( step => 'lista~2' ); print $root->describe(element => 'lista')," " ; # name value type comment # lista foo,bar list # append some data $root->load( step => q!hash_of_nodes:en foo.=" world"! ); print $root->grab('hash_of_nodes:en')->describe(element => 'foo')," " ; # name value type comment # foo "hello world" string DESCRIPTION
This module is used directly by Config::Model::Node to load serialized configuration data into the configuration tree. Serialized data can be written by the user or produced by Config::Model::Dumper while dumping data from a configuration tree. CONSTRUCTOR
new ( ) No parameter. The constructor should be used only by Config::Model::Node. load string syntax The string is made of the following items (also called "actions") separated by spaces: - Go up one node ! Go to the root node of the configuration tree. xxx Go down using "xxx" element. (For "node" type element) xxx:yy Go down using "xxx" element and id "yy" (For "hash" or "list" element with "node" cargo_type) xxx=~/yy/ Go down using "xxx" element and loop over the ids that match the regex. (For "hash") For instance, with "OpenSsh" model, you could do Host=~/.*.debian.org/ user='foo-guest' to set "foo-user" users for all your debian accounts. xxx~yy Delete item referenced by "xxx" element and id "yy". For a list, this is equivalent to "splice xxx,yy,1". This command does not go down in the tree (since it has just deleted the element). I.e. a '"-"' is generally not needed afterwards. xxx=zz Set element "xxx" to value "yy". load also accepts to set elements with a quoted string. (For "leaf" element) For instance "foo="a quoted string"". Note that you cannot embed double quote in this string. I.e "foo="a "quoted" string"" will fail. xxx~ Undef element "xxx" xxx=z1,z2,z3 Set list element "xxx" to list "z1,z2,z3". Use ",," for undef values, and "" for empty values. I.e, for a list "('a',undef,'','c')", use "a,,"",c". xxx:yy=zz For "hash" element containing "leaf" cargo_type. Set the leaf identified by key "yy" to value "zz". Using "xxx=~/yy/=zz" is also possible. xxx.=zzz Will append "zzz" value to current values (valid for "leaf" elements). xxx#zzz or xxx:yyy#zzz Element annotation. Can be quoted or not quoted. Note that annotations are always placed at the end of an action item. I.e. "foo#comment", "foo:bar#comment" or "foo:bar=baz#comment" are valid. "foo#comment:bar" is not valid. Quotes You can surround indexes and values with double quotes. E.g.: a_string=""titi" and "toto"" Methods load ( ... ) Load data into the node tree (from the node passed with "node") and fill values as we go following the instructions passed with "step". ("step" can also be an array ref). Parameters are: node node ref of the root of the tree (of sub-root) to start the load from. step A string or an array ref containing the steps to load. See above for a description of the string. experience Specify the experience level used during the load (default: "master"). The experience can be "intermediate advanced master". The load will raise an exception if the step of the load string tries to access an element with experience higher than user's experience. check Whether to check values while loading. Either "yes" (default), "no" or "skip". Loading with "skip" will discard bad values. AUTHOR
Dominique Dumont, (ddumont at cpan dot org) SEE ALSO
Config::Model,Config::Model::Node,Config::Model::Dumper perl v5.14.2 2012-11-09 Config::Model::Loader(3pm)
All times are GMT -4. The time now is 01:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy