apache pig - PIG : Columns into rows -


i have file contains :

id_v^id_f^id_s1,id_s2,id_s3,id_s4 id_v1^id_f1^id_s2,id_s3,id_s4 id_v2^id_f2^id_s2,id_s1,id_s4 

this file "^" delimited csv. want normalise way using pig :

id_v^id_f^id_s1 id_v^id_f^id_s2 id_v^id_f^id_s3 id_v^id_f^id_s4 id_v1^id_f2^id_s2 id_v1^id_f2^id_s3 id_v1^id_f2^id_s4 ... 

can me ?

regards

ok. let assume file.lets file name id_v.txt

id_v^id_f^id_s1,id_s2,id_s3,id_s4 id_v1^id_f1^id_s2,id_s3,id_s4 id_v2^id_f2^id_s2,id_s1,id_s4 

below pig code

a = load '/user/cloudera/inputfiles/id_v.txt' using pigstorage('^') as(v:chararray,f:chararray,data:chararray); b = foreach generate v,f,flatten(tokenize(data)) data; dump b;  

below o/p produced above code..

(id_v,id_f,id_s1) (id_v,id_f,id_s2) (id_v,id_f,id_s3) (id_v,id_f,id_s4) (id_v1,id_f1,id_s2) (id_v1,id_f1,id_s3) (id_v1,id_f1,id_s4) (id_v2,id_f2,id_s2) (id_v2,id_f2,id_s1) (id_v2,id_f2,id_s4) 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -