Rao
Rao

Reputation: 29

How to load data separated by :: in 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??

Upvotes: 0

Views: 106

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191701

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)

Upvotes: 2

Related Questions