- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to export the header of hive table into CSV file?
- Labels:
-
Apache Hive
Created ‎06-16-2018 08:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Created ‎06-18-2018 05:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Venkat Please try this :
hive -e 'set hive.cli.print.header=true; select * from your_Table' | sed 's/[\t]/,/g' > /home/yourfile.csv
Original answer https://stackoverflow.com/questions/17086642/how-to-export-a-hive-table-into-a-csv-file
Created ‎06-20-2018 05:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For this command I getting only the header.I want both header and data in the csv file
Created ‎06-21-2018 01:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should be getting both header and data with this command. I have just added "hive.cli.print.header=true" to print header along with data.
hive -e 'set hive.cli.print.header=true; select * from your_Table' | sed 's/[\t]/,/g' > /home/yourfile.csv
Whats the result you are seeing if you just do "select * from your_Table"? Does the table have the data?
Created ‎06-21-2018 02:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry @ssharma it is working but when I trying like this
- hive -e 'set hive.cli.print.header=true; create table test row format delimited fields terminated by '|' as select * from test1'>/home/yourfile.csv in this scenario it only showing the header not the whole data csv file
