How to load data separated by :: in pig

时间:2018-03-25 19:20:53

标签: hadoop apache-pig

I am having the text file in which fields are separated by :: like below.

124::2345::3::647483
234::5940::3::939390
340::3492::3::948284

How can i load the data in the pig latin and what is the parameter for using pigStorage??

1 个答案:

答案 0 :(得分:2)

PigStorage only accepts a single character.

Load the data on each line. Use STRSPLIT with a regex pattern to get the fields.

A = LOAD 'data.txt' USING PigStorage('\n');
B = FOREACH A GENERATE FLATTEN(STRSPLIT($0, '::'));

\d B Output

(124,2345,3,647483)
(234,5940,3,939390)
(340,3492,3,948284)