Debug:
1、
A = LOAD '/user/hue/task.txt' USING PigStorage(' ')
AS (col1,col2,col3);
DUMP A;
//输出结果前几行示例:
(>ggsnPDPRecord(21),,)
(-->recordType(0),,)
(-->networkInitiation(1),,)
(-->servedIMSI(3),,)
(-->ggsnAddress(4),,)
(---->iPTextV4Address(2),,)
//只显示了第一列,后面两列是空的,因为第一列和第二、三列之间间隔多个空格
2、
A = LOAD '/user/hue/task.txt' USING PigStorage(',')
AS (col1,col2,col3);
DUMP A;
//输出结果前几行示例:
(>ggsnPDPRecord(21),,)
(-->recordType(0) value: ggsnPDPRecord(19),,)
(-->networkInitiation(1) value: false(0),,)
(-->servedIMSI(3) value: 0x460026676534541f,,)
(-->ggsnAddress(4),,)
(---->iPTextV4Address(2) value: 221.177.57.165,,)
(-->chargingID(5) value: 1192448557,,)
//因为数据中没有逗号,所以每一行只是一个字段显示
3、尝试查找“-->servedIMSI(3)”
A = LOAD '/user/hue/task.txt' USING PigStorage(':') --划分方式为引号
AS (col1,col2); --划分为两个字段
B = FILTER A BY col1 matches'-->servedIMSI(3) value';
DUMP B;
//成功运行,但是没有输出结果
4、
A = LOAD '/user/hue/task.txt' USING PigStorage(':') --划分方式为引号
AS (col1,col2); --划分为两个字段
B = FILTER A BY col1 == '-->servedIMSI(3) value';
DUMP B; --STORE B INTO 'output/IMSI.csv';可以另存
//成功输出了servedIMSI(3)相关的内容
A = LOAD '/user/hue/task.txt' USING PigStorage(':') --划分方式为引号
AS (col1,col2); --划分为两个字段
B = FILTER A BY col1 == '-->chargingID(5) value';
STORE B INTO 'output/chargingID.csv';
//成功导出chargingID(5)
A = LOAD '/user/hue/task.txt' USING PigStorage(':') --划分方式为引号
AS (col1,col2); --划分为两个字段
B = FILTER A BY col1 == '-->recordOpeningTime(13) value';
STORE B INTO 'output/recordOpeningTime.csv';
//导出-->recordOpeningTime(13)
A = LOAD '/user/hue/task.txt' USING PigStorage(':') --划分方式为引号
AS (col1,col2); --划分为两个字段
B = FILTER A BY col1 == '-->duration(14) value';
STORE B INTO 'output/duration.csv';
//导出-->duration(14)
A = LOAD '/user/hue/task.txt' USING PigStorage(':') --划分方式为引号
AS (col1,col2); --划分为两个字段
B = FILTER A BY col1 == '-->nodeID(18) value';
STORE B INTO 'output/nodeID.csv';
//导出-->nodeID(18)
5、取出IMEISV的数据(含空格)
A = LOAD '/user/hue/task.txt' USING PigStorage(':') --划分方式为引号
AS (col1,col2); --划分为两个字段
B = FILTER A BY col1 == '-->servedIMEISV(29) value';
C = FOREACH B GENERATE col2; --取第二个字段
DUMP C;--STORE C INTO 'output/IMEISV_2.csv';
6、取出IMEISV的数据(不含空格)
A = LOAD '/user/hue/output/IMEISV_2.csv' USING PigStorage(' ') --划分方式为引号
AS (col1,col2); --划分为两个字段
B = FILTER A BY col1 == '-->servedIMEISV(29) value';
C = FOREACH B GENERATE col1; --取第一个字段
STORE C INTO 'output/IMEISV.csv';
//无论取字段一还是字段二,取出来的都是空
A = LOAD '/user/hue/output/IMEISV_2.csv' AS(col1);
B = FOREACH A GENERATE CONCAT('1', (chararray)col1);
STORE B INTO 'output/IMEISV_1.csv';
//在每一行字段前面加上一个1
A = LOAD '/user/hue/output/IMEISV_1.csv' USING PigStorage(' ') AS(col1,col2);
B = FOREACH A GENERATE col2;
STORE B INTO 'output/IMEISV.csv';
//取出正式的数据
_整理____________________________________________________________________________________________
step1
A = LOAD '/user/hue/task.txt' USING PigStorage(':') --划分方式为引号
AS (col1,col2); --划分为两个字段
B = FILTER A BY col1 == '-->servedIMEISV(29) value';
C = FOREACH B GENERATE col2; --取第二个字段
STORE C INTO 'output/IMEISV_2.csv';
step2
A = LOAD '/user/hue/output/IMEISV_2.csv' AS(col1);
B = FOREACH A GENERATE CONCAT('1', (chararray)col1);
STORE B INTO 'output/IMEISV_1.csv';
step3
A = LOAD '/user/hue/output/IMEISV_1.csv' USING PigStorage(' ') AS(col1,col2);
B = FOREACH A GENERATE col2;
STORE B INTO 'output/IMEISV.csv';
________________________________________________________________________________________________
7、
A = LOAD '/user/hue/output/IMEISV.csv' AS (col);
B = FOREACH A GENERATE SUBSTRING(col,2,8);
DUMP B;
STORE B INTO '/user/hue/output/sixnumber.csv';
//截取了前3-9位