|
|
DIPESH KUMAR SINGH 2012-05-08, 17:53
Hi,
I have data in a file which has schema, say like this: (stud_id, Physics, Chemistry, Bio, CS)
I need to generate an output which should contain (stud_id , xml_payload) for each record in my relation.
The type of dynamic xml i need to generate is like this:
<stud xmlns: www.w3.org .... ... > <stud_id> A-12 </stud_id> <subjects> <marks> <phy> 98 </phy> <chem>96 </chem> </marks> </subjects> </stud>
<stud xmlns: www.w3.org .... > <stud_id> A-102 </stud_id> <subjects> <marks> <phy> 98 </phy> <chem>96 </chem> <CS> 100</CS> </marks> </subjects> </stud>
Any suggestions on how to proceed on this? I am bit new to pig.
Thanks & Regards,
Dipesh
+
DIPESH KUMAR SINGH 2012-05-08, 17:53
-
Re: XML generation in Pig
Bill Graham 2012-05-08, 22:32
You could write a UDF that take the tuple and does string munging to produce the XML for a given record. Each <stud> element would be on a single line if that's ok.
This is approach is ugly in that you're manually building XML strings in Java, but it's quick and easy to implement. On Tue, May 8, 2012 at 10:53 AM, DIPESH KUMAR SINGH <[EMAIL PROTECTED]>wrote:
> Hi, > > I have data in a file which has schema, say like this: (stud_id, Physics, > Chemistry, Bio, CS) > > I need to generate an output which should contain (stud_id , xml_payload) > for each record in my relation. > > The type of dynamic xml i need to generate is like this: > > <stud xmlns: www.w3.org .... ... > > <stud_id> A-12 </stud_id> > <subjects> > <marks> > <phy> 98 </phy> > <chem>96 </chem> > </marks> > </subjects> > </stud> > > <stud xmlns: www.w3.org .... > > <stud_id> A-102 </stud_id> > <subjects> > <marks> > <phy> 98 </phy> > <chem>96 </chem> > <CS> 100</CS> > </marks> > </subjects> > </stud> > > Any suggestions on how to proceed on this? I am bit new to pig. > > Thanks & Regards, > > Dipesh >
-- *Note that I'm no longer using my Yahoo! email address. Please email me at [EMAIL PROTECTED] going forward.*
+
Bill Graham 2012-05-08, 22:32
-
Re: XML generation in Pig
DIPESH KUMAR SINGH 2012-05-09, 01:44
Thanks Bill.
On Wed, May 9, 2012 at 4:02 AM, Bill Graham <[EMAIL PROTECTED]> wrote:
> You could write a UDF that take the tuple and does string munging to > produce the XML for a given record. Each <stud> element would be on a > single line if that's ok. > > This is approach is ugly in that you're manually building XML strings in > Java, but it's quick and easy to implement. > > > On Tue, May 8, 2012 at 10:53 AM, DIPESH KUMAR SINGH > <[EMAIL PROTECTED]>wrote: > > > Hi, > > > > I have data in a file which has schema, say like this: (stud_id, Physics, > > Chemistry, Bio, CS) > > > > I need to generate an output which should contain (stud_id , xml_payload) > > for each record in my relation. > > > > The type of dynamic xml i need to generate is like this: > > > > <stud xmlns: www.w3.org .... ... > > > <stud_id> A-12 </stud_id> > > <subjects> > > <marks> > > <phy> 98 </phy> > > <chem>96 </chem> > > </marks> > > </subjects> > > </stud> > > > > <stud xmlns: www.w3.org .... > > > <stud_id> A-102 </stud_id> > > <subjects> > > <marks> > > <phy> 98 </phy> > > <chem>96 </chem> > > <CS> 100</CS> > > </marks> > > </subjects> > > </stud> > > > > Any suggestions on how to proceed on this? I am bit new to pig. > > > > Thanks & Regards, > > > > Dipesh > > > > > > -- > *Note that I'm no longer using my Yahoo! email address. Please email me at > [EMAIL PROTECTED] going forward.* >
-- Dipesh Kr. Singh
+
DIPESH KUMAR SINGH 2012-05-09, 01:44
|
|