how to load the data from local system to hdfs using PIG how to load the data from local system to hdfs using PIG hadoop hadoop

how to load the data from local system to hdfs using PIG


If your input file is at local then you can enter into grunt shell by typing pig -x local

If you enter into grunt shell then you can type the below statement

 record = LOAD  '/home/hadoop/Desktop/script/sample.csv' using PigStorage(',') as (id:int,name:chararray,year:chararray,rating:chararray,duration:int); dump record;

If your input file is not at local then first you need to copy that file from local to HDFS using below command

hadoop dfs -put <path of file at local>  <path of hdfs dir>

Once your file is loaded into HDFS you can enter to map reduce mode by typing pig

again grunt shell will be opened. ia assuming that your HDFS location is something like below LOAD statement

record = LOAD  '/user/hadoop/inputfiles/sample.csv' using PigStorage(',') as (id:int,name:chararray,year:chararray,rating:chararray,duration:int); dump record;


You can also use copyFromLocal command in grunt shell to move local file to hdfs.


open pig shell in local mode by pig -x local and if your file present at hdfs then you can use pig to open grant shell.

$pig -x localgrunt> movies = load '/home/hadoop/Desktop/script/sample.csv' using PigStorage(',') as (id:int,name:chararray,year:chararray,rating:chararray,duration:chararray);grunt> dump movies;