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
答案 0 :(得分:1)
将文件加载到单个字段中,然后使用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;
答案 1 :(得分:0)
尝试以下代码
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;