You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Marko Musnjak <ma...@gmail.com> on 2011/01/13 14:50:12 UTC

Adding a header line to output of Pig scripts

Hi,

What would be the best way to add a header line to the CSV files I save?
That would make the output much easier to read in excel... Right now I'm
thinking about loading a one-line file and doing a UNION, but if there's a
better way, your reccomendations are welcome

Bye,
Marko

Re: Adding a header line to output of Pig scripts

Posted by Dmitriy Ryaboy <dv...@gmail.com>.
Marko,
There is a handy PigStorageSchema storefunc
(org.apache.pig.piggybank.storage.PigStorageSchema) in the piggybank that
lets you do that:

/**
 *  This Load/Store Func reads/writes metafiles that allow the schema and
 *  aliases to be determined at load time, saving one from having to
manually
 *  enter schemas for pig-generated datasets.
 *
 *  It also creates a ".pig_headers" file that simply lists the delimited
aliases.
 *  This is intended to make export to tools that can read files with header
 *  lines easier (just cat the header to your data).
 *
 *  Due to StoreFunc limitations, you can only write the metafiles in
MapReduce
 *  mode. You can read them in Local or MapReduce mode.
 */


On Thu, Jan 13, 2011 at 5:50 AM, Marko Musnjak <ma...@gmail.com>wrote:

> Hi,
>
> What would be the best way to add a header line to the CSV files I save?
> That would make the output much easier to read in excel... Right now I'm
> thinking about loading a one-line file and doing a UNION, but if there's a
> better way, your reccomendations are welcome
>
> Bye,
> Marko
>