pig tutorial - apache pig tutorial - How to Store pig result to local file ? - pig latin - apache pig - pig hadoop




How to Store Data

  • We can store the loaded data in the file system using the store operator. This explains how to store data in Apache Pig using the Store operator.

Syntax

  • The syntax of the Store statement.
STORE Relation_name INTO ' required_directory_path ' 

Example

  • Consider that we have a file student_data.txt in HDFS with the following content.
001,Rajiv,Reddy,9848022337,Hyderabad
002,siddarth,Battacharya,9848022338,Kolkata
003,Rajesh,Khanna,9848022339,Delhi
004,Preethi,Agarwal,9848022330,Pune
005,Trupthi,Mohanthy,9848022336,Bhuwaneshwar
006,Archana,Mishra,9848022335,Chennai.

  • And we have read it into a relation student using the LOAD operator as shown below.
grunt> student = LOAD 'hdfs://localhost:9000/pig_data/student_data.txt' 
   USING PigStorage(',')
   as ( id:int, firstname:chararray, lastname:chararray, phone:chararray, 
   city:chararray );

  • We can merging everything to a single file then we can use the copyToLocal command in grunt
grunt> copyToLocal <src> <dest>

Related Searches to How to Store pig result to local file

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×