FAQ
Hi Ramana,

I believe using other tools like shell or perl will be better
althgouth I can think of a way using pig that is very tricky.

First write a new LoadFunc that add line num in each record (write a
new inputformat that generate only one split for each file, the output
should be:
1 raju
2 krishan
3 siva
4 venkat

Second, Join the two files by line number

The following is the script:

a = load '/a.txt' using YourLoadFunc as (line_num, val);
b = load '/b.txt' using YourLoadFunc as (line_num, val);
c = join a by line_num, b by line_num;
d = foreach c generate a::val, b::val;

dump d;

On Thu, Sep 2, 2010 at 2:26 AM, Ramana Venkata wrote:
Hi
I have 2 files, each file contains one column of data
I want to combine the two files into single file with two columns

ex:
file1.txt

raju
krishan
siva
venkat


file2.txt

CSE
IT
MECH
CIVIL

the output file should be like this

raju       CSE
krishan       IT
siva        MECH
venkat       CIVIL



How to do this pig script?


thanks
ramanaiah


--
Best Regards

Jeff Zhang

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
groupuser @
categoriespig, hadoop
postedSep 2, '10 at 3:15p
activeSep 6, '10 at 2:20a
posts3
users3
websitepig.apache.org

People

Translate

site design / logo © 2022 Grokbase