Reputation: 39
2017-01-01 15:35:18 I had heavy snacks
2017-02-01 12:45:19 I am feeling hungry
2017-03-01 10:25:19 I completed my work that is assigned
Upvotes: 0
Views: 30
Reputation: 1
Try below code
A = load 'data' using PigStorage ();
B = foreach A generate STRSPLIT($0,' ' ,3);
C = foreach B generate flatten($0);
D = foreach C generate $2,$1,$0;
Upvotes: 0
Reputation: 11080
Load the file into a single field and then use STRSPLIT.
A = LOAD '/path/sample.txt' USING TextLoader() AS (line:chararray);
B = FOREACH A GENERATE STRSPLIT(line,' ',3); --Note: 3 indicates the field line to be split into 3 parts based on the delimiter space.
DUMP B;
Upvotes: 1