3

My requirement is to generate multiple lines of output by using single line of input in pig scripting. What are the possible solutions?

Ashish
  • 5,723
  • 2
  • 24
  • 25

1 Answers1

7

The idea is to convert you input line into a bag and then flatten it. Here could be 2 cases:

Reading text:

txt = load '/pig_fun/input/text.txt' using TextLoader();
words = foreach txt generate TOKENIZE($0);
pivoted = foreach words generate FLATTEN($0);
dump pivoted;

Input:

My requirement is to generate multiple lines of output by using single line of input in pig scripting.
What are the possible solutions?

OUTPUT:

(My)
(requirement)
(is)
(to)
(generate)
(multiple)
(lines)
(of)
(output)
(by)
(using)
(single)
(line)
(of)
(input)
(in)
(pig)
(scripting.)
(What)
(are)
(the)
(possible)
(solutions?)

Reading columns and then pivoting them see Pivot table with Apache Pig

Community
  • 1
  • 1
alexeipab
  • 3,609
  • 14
  • 16