You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Ricardo Pompeu Ferreras <ri...@gmail.com> on 2014/09/04 18:43:57 UTC

Load CSV to hive

Hi,

How I create a table with this structure ?

The separte are , comma,
There are fields with "xx" date and "yyy" with value.

70268503,"2012-09-28 15:00:59",0,",01","18,01",,1,"2012-10-01 17:01:11",0,,

help please
-- 
Ricardo
SP, Brasil

Re: Load CSV to hive

Posted by Peyman Mohajerian <mo...@gmail.com>.
you could use: https://github.com/ogrodnek/csv-serde
That what i have done in the past, but with the latest version of Hive
there might be other options available too.


On Thu, Sep 4, 2014 at 12:43 PM, Ricardo Pompeu Ferreras <
ricardo.ferreras@gmail.com> wrote:

> Hi,
>
> How I create a table with this structure ?
>
> The separte are , comma,
> There are fields with "xx" date and "yyy" with value.
>
> 70268503,"2012-09-28 15:00:59",0,",01","18,01",,1,"2012-10-01 17:01:11",0,,
>
> help please
> --
> Ricardo
> SP, Brasil
>

Re: Load CSV to hive

Posted by Kim Chew <kc...@gmail.com>.
First, you need to give your csv file a header. For example,

col1,col2,col3,...etc.
70268503,"2012-09-28 15:00:59",0,",01","18,01",,1,"
2012-10-01 17:01:11",0,,

Then create the table with,

CREATE TABLE IF NOT EXISTS foo (
    col1     INT,
    col2     STRING,
    col3      INT
    .......
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE

Then load data into your table,

LOAD DATA INPATH '/user/me/myinput.csv' OVERWRITE INTO TABLE foo;

HTH

Kim

On Thu, Sep 4, 2014 at 9:43 AM, Ricardo Pompeu Ferreras <
ricardo.ferreras@gmail.com> wrote:

> Hi,
>
> How I create a table with this structure ?
>
> The separte are , comma,
> There are fields with "xx" date and "yyy" with value.
>
> 70268503,"2012-09-28 15:00:59",0,",01","18,01",,1,"2012-10-01 17:01:11",0,,
>
> help please
> --
> Ricardo
> SP, Brasil
>