apache pig - In Pig latin, am not able to load data as multiple tuples, please advice -


i not able load data multiple tuples, not sure mistake doing, please advise.

data.txt vineet  1   pass    govt hisham  2   pass    prvt raj 3   fail    prvt 

i want load them 2 touples.

a = load 'data.txt' using pigstorage('\t') (t1:tuple(name:bytearray, no:int), t2:tuple(result:chararray, school:chararray)); 

or

a = load 'data.txt' using pigstorage('\t') (t1:(name:bytearray, no:int), t2:(result:chararray, school:chararray)); 

dump a; below data displayed in form of new line, dont know why not able read actual data data.txt.

(,) (,) (,) 

as input data not stored tuple wont able read directly in tuple.

one feasible approach read data , form tuple required fields.

pig script :

a = load 'a.csv' using pigstorage('\t') (name:chararray,no:int,result:chararray,school:chararray); b = foreach generate (name,no) t1:tuple(name:chararray, no:int), (result,school) t2:tuple(result:chararray, school:chararray); dump b; 

input : a.csv

vineet  1   pass    govt hisham  2   pass    prvt raj 3   fail    prvt 

output : dump b:

((vineet,1),(pass,govt)) ((hisham,2),(pass,prvt)) ((raj,3),(fail,prvt)) 

output : describe b :

b: {t1: (name: chararray,no: int),t2: (result: chararray,school: chararray)} 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -