Is it possible to export data from HIVE table directly into csv file including headers?


4 Answer(s)


hi Trinadh,

It is possible to export hive table data to csv, try the following

hive -e 'select books from table' | sed 's/[[:space:]]\+/,/g' > /home/lvermeer/temp.csv

you can also try this

set hive.io.output.fileformat = CSVTextFile;

INSERT OVERWRITE LOCAL DIRECTORY 'dir_path' SELECT FIELD1, FIELD2, FIELD3 FROM TABLE1;

Thanks a lot!

Trinadh

Hi,

Both these above scripts work only in SHELL right?