Monday, September 26, 2016

My first Pig Script to count number of occurances of IP address from the log file

Hello all,

I'm glad to inform you all that today i have successfully wrote a PIG script to generate count of IP address from the 26 Lakhs of records.

I got chance to handle big data issue in my current company & i used PIG script to execute the task,

Here is my script to count the occurances of IP addresss from log file


 Ldata = LOAD '/user/cloudera/Pigdata/totalIPcount.txt' AS (line:chararray);
IP = FOREACH Ldata GENERATE FLATTEN(TOKENIZE(line)) as IPaddress;
grouped = GROUP IP BY IPaddress;
IPCount= FOREACH grouped GENERATE group, COUNT(IP);
DUMP IPCount;  OR  STORE IPCount INTO '/Pigdata'


Thanks
Pradeep



No comments:

Post a Comment