1、導(dǎo)入
將CSV文件導(dǎo)入到hive數(shù)據(jù)庫,具體操作如下,
首先在hive中創(chuàng)建自己的table, 并且設(shè)置以逗號分隔。
create table if not exists tmp.hb_label_C(
sample_cat string,
reg_mob_md5 string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE;
然后
desc formatted tmp.hb_label_C
確定tmp.hb_label_C表的分布式文件路徑
最后在linux命令行輸入
hdfs dfs -put label_C.csv hdfs://nameservice1/user/hive/warehouse/tmp.db/hb_label_C
查看結(jié)果
select * from tmp.hb_label_C limit 10;
2、導(dǎo)出
使用beeline重定向文章來源:http://www.zghlxwxcb.cn/news/detail-572965.html
beeline -e "select * from tmp.install_uninstall_pred_res_online_v1 where tail<=9" > hb_torch_feature.csv
同時使用以下方式導(dǎo)出數(shù)據(jù)帶表頭文章來源地址http://www.zghlxwxcb.cn/news/detail-572965.html
beeline -e "select * from tmp.install_uninstall_pred_res_online_v1 where tail<=9" |sed '1s/^/md5_phone\n/' > hb_torch_feature.csv
到了這里,關(guān)于hive 導(dǎo)入導(dǎo)出csv文件的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!