Apache Pig - TextLoader ()

La función Pig Latin TextLoader() es una función de carga que se utiliza para cargar datos no estructurados en formato UTF-8.

Sintaxis

A continuación se muestra la sintaxis de TextLoader() función.

grunt> TextLoader()

Ejemplo

Supongamos que hay un archivo con nombre stu_data.txt en el directorio HDFS llamado /data/ Como se muestra abajo.

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

Ahora carguemos el archivo anterior usando el TextLoader() función.

grunt> details = LOAD 'hdfs://localhost:9000/pig_data/stu_data.txt' USING TextLoader();

Puede verificar los datos cargados utilizando el operador Dump.

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)