Hive 导入excel file 或CSV

1.上传文件到linux 文件系统

2.在HDFS上
hadoop fs -mkdir /Ken

3.添加linux 文件系统的文件到HDFS
hadoop fs -put ./Findings.csv /Ken

4.建表
hive
show databases;
use default;
create table Findings(
Finding_ID_vw string,
Assessment_Type_vw string,
Short_Description_vw string,
Finding_vw string,
Status_vw string,
Criticality_vw string,
Related_Assessment_Scheduling_Record_vw string,
Master_Assessment_Name_vw string,
Vulnerability_Type_vw string,
Finding_Cause_vw string,
Date_Closed_vw string,
Report_Published_Date_vw string,
Due_Date_vw string,
Revised_Due_Date_vw string,
Exception_End_Date_vw string,
Geographic_Unit_vw string,
Growth_Platform_vw string,
Operating_Group_vw string,
Assigned_To_vw string,
Accountable_Executive_vw string,
Assessor_vw string,
Client_Account_Lead_vw string,
Revised_Criticality_vw string,
MA_Assessment_vw string)
;

5. load 数据

load data inpath '/Ken/Findings.csv' into table Finding;

-
---------------------------------------------------------
如果excel file 有需要转义的字符逗号, 或者引号 “ 和 ‘


首先把这一列的格式换成文本型text默认是general




然后再save as cvs(逗号分隔的)

最后导出来的cvs文件 文本类型的列会被 "双引号"括起来,然后再导入hive就行了



你可能感兴趣的:(Hive)