1-844-696-6465 (US)        +91 77600 44484        help@dezyre.com

How to run pig program without using DUMP



0
file name: wordcount.pig

book = LOAD '/data/small/war_and_peace.txt' USING PigStorage() AS (lines:chararray);
words1 = FOREACH book GENERATE FLATTEN(TOKENIZE(lines)) AS word;
wgroup = GROUP words1 by word;
wcount = FOREACH wgroup GENERATE group AS dword, COUNT(words1) AS dcount;
wsort = ORDER wcount BY dcount DESC;
STORE wcount INTO '/Output/Pig/WordCount';

Trying to run the above file in Pig but getting below error. Please help me how to run the pig program without using DUMP.

Ran the blow command to run the file:

pig /home/hadoop/wordcount.pig

Getting below error:

ERROR 1000: Error during parsing. Encountered " "pig "" at line 12, column 1.
Was expecting one of:

"cat" ...
"clear" ...
"fs" ...
"sh" ...
"cd" ...
"cp" ...
"copyFromLocal" ...
"copyToLocal" ...
"dump" ...
"describe" ...
"aliases" ...
"explain" ...
"help" ...
"history" ...
"kill" ...
"ls" ...
"mv" ...
"mkdir" ...
"pwd" ...
"quit" ...
"register" ...
"rm" ...
"rmf" ...
"set" ...
"illustrate" ...
"run" ...
"exec" ...
"scriptDone" ...
"" ...
"" ...
...
";" ...

1 Answer(s)


0

Hi Venkata,
Pig use DUMP to show the output.
You can save the output in txt and open with any text editor.
For example:
a = LOAD 'example.csv' USING PigStorage(';');
b = FOREACH a GENERATE $0,$1,$2,$3,$6,$7,$8,$9,$11,$12,$13,$14,$20,$24,$25;
STORE b INTO ‘myoutput.txt’ using PigStorage(';');
where ';' is delimiter for separating the outputs store under myoutput.txt

Hope this helps.

Your Answer

Click on this code-snippet-icon icon to add code snippet.

Upload Files (Maximum image file size - 1.5 MB, other file size - 10 MB, total size - not more than 50 MB)

Email
Password