pig:列到行

jgwigjjp  于 2021-06-25  发布在  Pig
关注(0)|答案(1)|浏览(494)

我有一个包含以下内容的文件:

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

此文件是以“^”分隔的csv。我想用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
...

有人能帮我吗?
当做

x7yiwoj4

x7yiwoj41#

好 啊。假设这是我的文件。假设文件名是id\u 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

以下是清管器代码

A = load '/user/cloudera/inputfiles/id_v.txt' using PigStorage('^') as(v:chararray,f:chararray,data:chararray);
B = foreach A generate v,f,FLATTEN(TOKENIZE(data)) as data;
dump B;

以下是上述代码生成的订单。。

(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)

相关问题