Store pig result in a text file

19,694

Yes you will be able to store your result in myoutput.txt and you can load the data into file with any delimiter you want using PigStorage.

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(';');
Share:
19,694

Related videos on Youtube

user1931853
Author by

user1931853

Updated on August 18, 2022

Comments

  • user1931853
    user1931853 over 1 year

    Hi stackoverflow community;

    i'm totally new to pig, i want to STORE the result in a text file and name it as i want. is it possible do this using STORE function.

    My code:

    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’;
    

    Thanks.

    • LiMuBei
      LiMuBei almost 9 years
      Technically, this will create a directory named 'myoutput' in which there will be one or more part-... files.
  • Greg Hilston
    Greg Hilston over 5 years
    Just a note to anyone doing this, you should be able to run grunt> pwd, to see where the output is stored on your local file system.