You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by kentkong_work <ke...@163.com> on 2013/07/10 06:48:10 UTC

export csv, use ',' as split

hi here,
   I create a table like this and put a lot data into it.
   then I export query result into csv file like this:
    hive -e myquery >> result.csv

   but the csv uses tab as split.
   how to make hive use ','? thanks!

CREATE TABLE if not exists upload_users(
  username string, 
  mobile string, 
  id_type string, 
  id_no string, 
  email string, 
  address string, 
  validate_time string
) partitioned by (fileid string) 
row format delimited fields terminated by "\,";

   

Re: export csv, use ',' as split

Posted by Nitin Pawar <ni...@gmail.com>.
hive create table is different than the hive query output,

hive by default uses tab as output column separator on console. if you want
to change to csv, why don't you just use sed and replace tab with ","

if you want a csv generated out of the query itself then create a temporary
external table with "," as separator and then load data using your query .
Its a long route.

Wait for sometime so that others can reply with better suggestion if mines
are not suitable for you


On Wed, Jul 10, 2013 at 10:18 AM, kentkong_work <ke...@163.com>wrote:

> **
> hi here,
>    I create a table like this and put a lot data into it.
>    then I export query result into csv file like this:
>     hive -e myquery >> result.csv
>
>    but the csv uses tab as split.
>    how to make hive use ','? thanks!
>
> CREATE TABLE if not exists upload_users(
>   username string,
>   mobile string,
>   id_type string,
>   id_no string,
>   email string,
>   address string,
>   validate_time string
> ) partitioned by (fileid string)
> row format delimited fields terminated by "\,";
>
>
>



-- 
Nitin Pawar

Re: export csv, use ',' as split

Posted by Navis류승우 <na...@nexr.com>.
Fixed in hive-0.11.0

https://issues.apache.org/jira/browse/HIVE-3682

2013/7/11 Sanjay Subramanian <Sa...@wizecommerce.com>:
> Hive does not have a output delimiter specifier yet (not sure if 0.11.x may
> have it)
>
> But for now please try the following
>
> hive -e myquery | sed 's/\t/,/g' >> result.csv
>
> Good luck
>
> Sanjay
>
> From: kentkong_work <ke...@163.com>
> Reply-To: "user@hive.apache.org" <us...@hive.apache.org>
> Date: Tuesday, July 9, 2013 9:48 PM
> To: user <us...@hive.apache.org>
> Subject: export csv, use ',' as split
>
> hi here,
>    I create a table like this and put a lot data into it.
>    then I export query result into csv file like this:
>     hive -e myquery >> result.csv
>
>    but the csv uses tab as split.
>    how to make hive use ','? thanks!
>
> CREATE TABLE if not exists upload_users(
>   username string,
>   mobile string,
>   id_type string,
>   id_no string,
>   email string,
>   address string,
>   validate_time string
> ) partitioned by (fileid string)
> row format delimited fields terminated by "\,";
>
>
>
> CONFIDENTIALITY NOTICE
> ======================
> This email message and any attachments are for the exclusive use of the
> intended recipient(s) and may contain confidential and privileged
> information. Any unauthorized review, use, disclosure or distribution is
> prohibited. If you are not the intended recipient, please contact the sender
> by reply email and destroy all copies of the original message along with any
> attachments, from your computer system. If you are the intended recipient,
> please be advised that the content of this message is subject to access,
> review and disclosure by the sender's Email System Administrator.

Re: export csv, use ',' as split

Posted by Sanjay Subramanian <Sa...@wizecommerce.com>.
Hive does not have a output delimiter specifier yet (not sure if 0.11.x may have it)

But for now please try the following

hive -e myquery | sed 's/\t/,/g' >> result.csv

Good luck

Sanjay

From: kentkong_work <ke...@163.com>>
Reply-To: "user@hive.apache.org<ma...@hive.apache.org>" <us...@hive.apache.org>>
Date: Tuesday, July 9, 2013 9:48 PM
To: user <us...@hive.apache.org>>
Subject: export csv, use ',' as split

hi here,
   I create a table like this and put a lot data into it.
   then I export query result into csv file like this:
    hive -e myquery >> result.csv

   but the csv uses tab as split.
   how to make hive use ','? thanks!

CREATE TABLE if not exists upload_users(
  username string,
  mobile string,
  id_type string,
  id_no string,
  email string,
  address string,
  validate_time string
) partitioned by (fileid string)
row format delimited fields terminated by "\,";



CONFIDENTIALITY NOTICE
======================
This email message and any attachments are for the exclusive use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message along with any attachments, from your computer system. If you are the intended recipient, please be advised that the content of this message is subject to access, review and disclosure by the sender's Email System Administrator.