hadoop - Remove brackets and commas in output from Pig -
hadoop - Remove brackets and commas in output from Pig -
currently output below:
((130,1)) ((131,1)) ((132,1)) ((133,1)) ((137,1)) ((138,2)) ((139,1)) ((140,1)) ((142,2)) ((143,1))
i want have like:
130 1 131 1 132 1
my code given below:
a = load 'user-links-small.txt' (user_a: int, user_b: int); b = order user_a; grouped = cogroup b user_a; c = foreach grouped generate count(b); d = cogroup c $0; e = foreach d generate($0, count($1)); dump e;
i looking through these forums, , suggested way coding user-defined function. can seek that, new pig , want larn functions bit more in details. found on flatten() can't output. there way remove brackets , commas shown? in advance help!
if utilize dump command default output stored tuples (ie fields dumped within function bracket separated delimiter ',')
you can remove first bracket using flatten operator , sec bracket , ',' using store command.
try
e = foreach d generate flatten(($0, count($1))); store e 'output' using pigstorage(' ');
go folder 'output' , check file name starts part*. see output this 130 1 131 1 132 1
hadoop apache-pig
Comments
Post a Comment