Example of loading CSV file and defining schema(HandsOn).
 
categoriesWithSchema = LOAD '/user/cloudera/Training/pig/cat.txt' USING PigStorage(',') AS (id:int,subId:int,categoryName:chararray); 
DESCRIBE categoriesWithSchema ;
categoriesWithSchema: {id: int,subId: int,categoryName: chararray}
 
Example with Tab separated file(HandsOn)
  • Step 1 : Download tab separated file
  • Step 2 : Upload this file in HDFS
  • Step 3 : Now write Pig Script to load this file.
categoriesWithSchemaTab = LOAD '/user/cloudera/Training/pig/catTab.txt' AS (id:int,subId:int,categoryName:chararray); 
DESCRIBE categoriesWithSchemaTab;
categoriesWithSchemaTab: {id: int,subId: int,categoryName: chararray}
DUMP categoriesWithSchemaTab ;
ILLUSTRATE categoriesWithSchemaTab ;
--------------------------------------------------------------------------------------
| categoriesWithSchemaTab     | id:int    | subId:int    | categoryName:chararray    | 
--------------------------------------------------------------------------------------
|                             | 51        | 8            | NHL                       | 
--------------------------------------------------------------------------------------
Loading Data from HBase 
divs = load 'myData' using HBaseStorage();