input.txt
Pearson Charles
James Michael
Smith Linda
PigScript:
A = LOAD 'input.txt' AS line;
B = FOREACH A GENERATE FLATTEN(STRSPLIT(line,'\\s+',2)) AS (firstname:chararray,lastname:chararray);
C = FOREACH B GENERATE firstname,lastname;
DUMP C;
Output:
(Pearson,Charles)
(James,Michael)
(Smith,Linda)
1条答案
按热度按时间pvcm50d11#
您可以尝试下面的示例代码
我现在做的是
1.将每一行读作单列
2.使用空格作为分隔符应用strsplit函数
3.将firstname和lastname存储到两个不同的列中
查看此链接的更多信息
http://pig.apache.org/docs/r0.13.0/func.html#strsplit