hadoophivehiveql

hive -e with delimiter


I am trying to export the data from hive table as below but it is generating file with tab as delimiter. Is it possible to specify the delimiter as comma or tab when exporting it?

hive -e "
use default;
set hive.cli.print.header=true;
select * from test1;
    " > /temp/test.txt (or .csv) 

Thanks J


Solution

  • You can pipe your data and use a simple sed command to convert your data into required output format. Below sed command replaces tab with comma. Default output is Tab. You can change the output accordingly.

    hive -e "use default;set hive.cli.print.header=true;select * from test1;" | sed 's/[\t]/,/g' >/temp/test.csv