- Apache Pig Tutorial
- Apache Pig - Home
- Apache Pig Introduction
- Apache Pig - Overview
- Apache Pig - Architecture
- Apache Pig Environment
- Apache Pig - Installation
- Apache Pig - Execution
- Apache Pig - Grunt Shell
- Pig Latin
- Pig Latin - Basics
- Load & Store Operators
- Apache Pig - Reading Data
- Apache Pig - Storing Data
- Diagnostic Operators
- Apache Pig - Diagnostic Operator
- Apache Pig - Describe Operator
- Apache Pig - Explain Operator
- Apache Pig - Illustrate Operator
- Grouping & Joining
- Apache Pig - Group Operator
- Apache Pig - Cogroup Operator
- Apache Pig - Join Operator
- Apache Pig - Cross Operator
- Combining & Splitting
- Apache Pig - Union Operator
- Apache Pig - Split Operator
- Pig Latin Built-In Functions
- Apache Pig - Eval Functions
- Load & Store Functions
- Apache Pig - Bag & Tuple Functions
- Apache Pig - String Functions
- Apache Pig - date-time Functions
- Apache Pig - Math Functions
- Other Modes Of Execution
- Apache Pig - User-Defined Functions
- Apache Pig - Running Scripts
- Apache Pig Useful Resources
- Apache Pig - Quick Guide
- Apache Pig - Useful Resources
- Apache Pig - Discussion
Apache Pig - TextLoader()
The Pig Latin function TextLoader() is a Load function which is used to load unstructured data in UTF-8 format.
Syntax
Given below is the syntax of TextLoader() function.
grunt> TextLoader()
Example
Let us assume there is a file with named stu_data.txt in the HDFS directory named /data/ as shown below.
001,Rajiv_Reddy,21,Hyderabad 002,siddarth_Battacharya,22,Kolkata 003,Rajesh_Khanna,22,Delhi 004,Preethi_Agarwal,21,Pune 005,Trupthi_Mohanthy,23,Bhuwaneshwar 006,Archana_Mishra,23,Chennai 007,Komal_Nayak,24,trivendram 008,Bharathi_Nambiayar,24,Chennai
Now let us load the above file using the TextLoader() function.
grunt> details = LOAD 'hdfs://localhost:9000/pig_data/stu_data.txt' USING TextLoader();
You can verify the loaded data using the Dump operator.
grunt> dump details; (001,Rajiv_Reddy,21,Hyderabad) (002,siddarth_Battacharya,22,Kolkata) (003,Rajesh_Khanna,22,Delhi) (004,Preethi_Agarwal,21,Pune) (005,Trupthi_Mohanthy,23,Bhuwaneshwar) (006,Archana_Mishra,23,Chennai) (007,Komal_Nayak,24,trivendram) (008,Bharathi_Nambiayar,24,Chennai)
apache_pig_load_store_functions.htm
Advertisements
To Continue Learning Please Login
Login with Google