Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert fields to rows in Pig?

I want to convert fields to rows in Pig.

from input.txt

1 2 3 4 5 6 7 8 9

delimeter between fields is '\t'.

to output.txt

1 2 3 4 ... but I must not use TOKENIZER because the content of fields might be a sentence. Please help me. Many Thanks.

like image 200
민호 이 Avatar asked Jan 16 '23 03:01

민호 이


1 Answers

I think alexeipab's answer is the right direction. Here is a simple example:

> A = load 'input.txt';
> dump A
(0,1,2,3,4,5,6,7,8,9)
> B = foreach A generate FLATTEN(TOBAG(*));
> dump B
(0)
(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
like image 200
cyang Avatar answered Feb 15 '23 08:02

cyang