in reply to Merge Columns of Multiple files based on Multiple Common Column

Have you seen join - join two files according to a common key?

  • Comment on Re: Merge Columns of Multiple files based on Multiple Common Column

Replies are listed 'Best First'.
Re^2: Merge Columns of Multiple files based on Multiple Common Column
by deepak2027 (Initiate) on May 03, 2013 at 06:57 UTC

    Corion, thx for the response, but this join is not able
    to join based on multiple columns
    I am not sure how to assign the values to @left_key_colls and @right_key_colls

      Either you hardcode them in the program, or you read Getopt::Long, which will explain to you how an option is handled if it is given multiple times.

      Also, as I now see, there is documentation at the bottom of the file which shows exactly your use case of specifying multiple columns. Maybe you should read that documentation first?

      I have tried the following: (join.pl is Corion's script)

      C:\scripts>perl join.pl --null "--" --left 1,2,3 --right 1,2,3 --delim +iter " " --missing 1 --missing 2 file1.txt file2.txt > file12.txt C:\scripts>perl join.pl --null "--" --left 1,2,3 --right 1,2,3 --delim +iter " " --missing 1 --missing 2 file12.txt file3.txt ID NAME date Val1 Val2 Val3 Val4 Val101 Val102 Val103 Val104 Val101 Va +l102 Val103 Val104 1 ABC 04-05-2013 10 11 12 13 50 51 52 53 -- -- -- -- 2 XYZ 04-05-2013 21 22 23 24 -- -- -- -- -- -- -- -- 1 ABC 05-05-2013 30 31 32 33 -- -- -- -- 60 61 62 63 2 XYZ 05-05-2013 41 42 43 44 -- -- -- -- 71 72 73 74

      So nearly there...