Sponsored Content
Top Forums Shell Programming and Scripting Joining files using awk not extracting all columns from File 2 Post 302970610 by venkat_reddy on Friday 8th of April 2016 05:44:07 PM
Old 04-08-2016
Thanks for the response

File1 will have more columns than File2 .Both have various columns with different formats i.e CHAR,DATE,TIMESTAMP etc. Both have "," as delimitiers.

I tried the code given by you but unfortunately it is not the output I'm expecting

Below is the expected output for the same files you used above:

Code:
1,P,PP,PPP,20160407,2016-04-07 13:55:00,2016-04-07 19:00:25,07-APR-16 07.12.40.839372 PM,PP,1
2,K,KK,KKK,20160407,2016-04-07 13:59:00,2016-04-07 19:00:25,07-APR-16 07.30.14.092718 PM,KK,2
3,C,CC,CCC,20160407,2016-04-07 23:06:30,2016-04-07 23:10:35,07-APR-16 11.21.17.934001 PM,CC,3
4,L,LL,LLL,20160407,2016-04-07 18:05:00,2016-04-08 00:30:31,08-APR-16 12.44.24.451781 AM,LL,4
5,M,MM,MMM,20160407,2016-04-08 03:08:00,2016-04-08 03:08:48,08-APR-16 03.30.41.496570 AM,MM,13
6,N,NN,NNN,20160407,2016-04-08 00:31:04,2016-04-08 00:31:04,08-APR-16 02.56.20.942287 AM,NN,11
8,O,OO,OOO,20160407,2016-04-07 21:25:00,2016-04-07 23:30:24,08-APR-16 01.16.25.267521 AM,OO,5
9,K,KK,KKK,20160407,2016-04-07 20:13:32,2016-04-07 20:32:35,,,
10,S,SS,SSS,20160407,2016-04-07 04:00:27,2016-04-07 18:25:54,08-APR-16 02.21.08.688799 AM,SS,7
11,T,TT,TTT,20160407,2016-04-07 11:13:47,2016-04-07 18:27:05,08-APR-16 04.45.32.112525 AM,TT,14
12,R,RR,RRR,20160407,2016-04-07 03:36:24,2016-04-07 18:27:39,08-APR-16 02.37.31.112826 AM,RR,9
12,R,RR,RRR,20160407,2016-04-07 16:18:01,2016-04-07 18:27:39,08-APR-16 02.37.31.112826 AM,RR,9


I need all the data from File 1 along with data from File 2 on matched attribute i.e COLUMN 1 in both files(Left Outer join ). In case of non- matching attribute, I need null values for the columns being extracted in from File 2.


Hope you got my requirement.

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Joining columns from two files, if the key matches

I am trying to join/paste columns from two files for the rows with matching first field. Any help will be appreciated. Files can not be sorted and may not have all rows in both files. Thanks. File1 aaa 111 bbb 222 ccc 333 File2 aaa sss mmmm ccc kkkk llll ddd xxx yyy Want to... (1 Reply)
Discussion started by: sk_sd
1 Replies

2. Shell Programming and Scripting

Joining two files based on columns/fields

I've got two files, File1 and File2 File 1 has got combination of col1, col2 and col3 which comes on file2 as well, file2 does not get col4. Now based on col1, col2 and col3, I would like to get col4 from file1 and all the columns from file2 in a new file Any ideas? File1 ------ Col1 col2... (11 Replies)
Discussion started by: rudoraj
11 Replies

3. Shell Programming and Scripting

extracting columns with awk

Friends, I have a file with fileds in the following order sda 4.80 114.12 128.69 978424 1103384 sdb 0.03 0.40 0.00 3431 0 sda 1.00 0.00 88.00 0 176 sdb ... (14 Replies)
Discussion started by: achak01
14 Replies

4. Shell Programming and Scripting

Transposing column to row, joining with another file, then sorting columns

Hello! I am very new to Linux and I do not know where to begin... I have a column with >64,000 elements (that are not in numberical order) like this: name 2 5 9 . . . 64,000 I would like to transpose this column into a row that will later become the header of a very large file... (2 Replies)
Discussion started by: doobedoo
2 Replies

5. UNIX for Dummies Questions & Answers

Extracting columns from multiple files with awk

hi everyone! I already posted it in scripts, I'm sorry, it's doubled I'd like to extract a single column from 5 different files and put them together in an output file. I saw a similar question for 2 input files, and the line of code workd very well, the code is: awk 'NR==FNR{a=$2; next}... (1 Reply)
Discussion started by: orcaja
1 Replies

6. Shell Programming and Scripting

Extracting columns from multiple files with awk

hi everyone! I'd like to extract a single column from 5 different files and put them together in an output file. I saw a similar question for 2 input files, and the line of code workd very well, the code is: awk 'NR==FNR{a=$2; next} {print a, $2}' file1 file2 I added the file3, file4 and... (10 Replies)
Discussion started by: orcaja
10 Replies

7. Shell Programming and Scripting

NR==FNR trick for joining columns from two files

foo.txt 1 rs2887286 0 1145994 C T 1 rs1240743 0 1323299 C A 1 rs1695824 0 1355433 G T 1 rs3766180 0 1468016 G A 1 rs7519837 0 1500664 A G 1 rs2272908 0 ... (12 Replies)
Discussion started by: genehunter
12 Replies

8. Shell Programming and Scripting

Other alternative for joining together columns from multiple files

Hi again, I have monthly one-column files of roughly around 10 years. Is there a more efficient way to concatenate these files column-wise other than using paste command? For instance: file1.txt 12 13 15 12 file2.txt 14 15 18 19 file3.txt 20 21 (8 Replies)
Discussion started by: ida1215
8 Replies

9. UNIX for Dummies Questions & Answers

Joining different columns from multiple files

Hello again, I am trying to join 3rd column of 3 files into the end on one file and save it separately... my data looks like this file 1 Bob, Green, 80 Mark, Brown, 70 Tina, Smith, 60 file 2 Bob, Green, 70 Mark, Brown, 60 Tina, Smith, 50 file 3 Bob, Green, 50 Mark, Brown,60 Tina,... (6 Replies)
Discussion started by: A-V
6 Replies

10. Shell Programming and Scripting

Joining Two Files Matching Two Columns

Hi All, I am looking to join two files where column 1 of file A matches with column 1 of file B and column 5 of files A matches with column 2 of file B. After joining the files based on above condition, out should contain entire line of file A and column 3, 4 and 5 of file B. Here is sample... (8 Replies)
Discussion started by: angshuman
8 Replies
libapache2-mod-perl2-2.0.7::docs::api::APR::UUID(3pm)	User Contributed Perl Documentation  libapache2-mod-perl2-2.0.7::docs::api::APR::UUID(3pm)

NAME
APR::UUID - Perl API for manipulating APR UUIDs Synopsis use APR::UUID (); # get a random UUID and format it as a string my $uuid = APR::UUID->new->format; # $uuid = e.g. 'd48889bb-d11d-b211-8567-ec81968c93c6'; # same as the object returned by APR::UUID->new my $uuid_parsed = APR::UUID->parse($uuid); Description "APR::UUID" is used to get and manipulate random UUIDs. It allows you to "create" random UUIDs, which when "formatted" returns a string like: 'd48889bb-d11d-b211-8567-ec81968c93c6'; which can be parsed back into the "APR::UUID" object with "parse()". API
"APR::UUID" provides the following functions and/or methods: "format" Convert an "APR::UUID object" object into a string presentation: my $uuid_str = $uuid->format; obj: $uuid ( "APR::UUID object" ) ret: $uuid_str returns a string representation of the object (.e.g 'd48889bb-d11d-b211-8567-ec81968c93c6'). since: 2.0.00 "new" Create a "APR::UUID object" using the random engine: my $uuid = APR::UUID->new; class: "APR::UUID" ( "APR::UUID class" ) ret: $uuid ( "APR::UUID object" ) since: 2.0.00 "DESTROY" $uuid->DESTROY; obj: "APR::UUID" ( "APR::UUID object" ) ret: no return value since: 2.0.00 Do not call this method, it's designed to be only called by Perl when the variable goes out of scope. If you call it yourself you will get a segfault when perl will call DESTROY on its own. "parse" Convert a UUID string into an "APR::UUID object" object: $uuid = APR::UUID->parse($uuid_str) arg1: $uuid_str (string) UUID string (.e.g 'd48889bb-d11d-b211-8567-ec81968c93c6') ret: $uuid ( "APR::UUID object" ) The new object. since: 2.0.00 See Also mod_perl 2.0 documentation. Copyright mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. Authors The mod_perl development team and numerous contributors. perl v5.14.2 2011-02-08 libapache2-mod-perl2-2.0.7::docs::api::APR::UUID(3pm)
All times are GMT -4. The time now is 05:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy