title: Apache Pig: Merging list of attributes into a single tuple
body: <p>I receive data in the form</p>
  
  <pre><code>id1|attribute1a,attribute1b|attribute2a|attribute3a,attribute3b,attribute3c....
  id2||attribute2b,attribute2c|..
  </code></pre>
  
  <p>I'm trying to merge it all into a form where I just have a bag of tuples of an id field followed by a tuple containing a list of all my other fields merged together.</p>
  
  <p>(id1,(attribute1a,attribute1b,attribute2a,attribute3a,attribute3b,attribute3c...))
  (id2,(attribute2b,attribute2c...))</p>
  
  <p>Currently I fetch it like</p>
  
  <pre><code>my_data = load '$input' USING PigStorage(|) as 
  (id:chararray, attribute1:chararray, attribute2:chararray)...
  </code></pre>
  
  <p>then I've tried all combinations of FLATTEN, TOKENIZE, GENERATE, TOTUPLE, BagConcat, etc. to massage it into the form I want, but I'm new to pig and just can't figure it out. Can anyone help? Any open source UDF libraries are fair game.</p>