- 将excel数据转成文本数据(.txt)
- 将该txt文件导入Linux指定目录中
- 转换编码格式,在指定目录下执行如下命令:piconv -f gb2312 -t UTF-8 CompanyCode.txt > c.txt
- ,根据文档中的列,创建表,建表语句如下:
create external table if not exists `dwd.dwd_brand_rank_base_tmp`
(
`category_name` string comment '品类名称',
`category_id` string comment '品类id',
`first_brand_name` string comment '一档品牌名称',
`first_brand_id` string comment '一档品牌ID',
`second_brand_name` string comment '二档品牌名称',
`second_brand_id` string comment '二档品牌ID',
`third_brand_name` string comment '三档品牌名称',
`third_brand_id` string comment '三档品牌ID'
)
comment '品类品牌关系映射表'
ROW format delimited
fields terminated by '\t'
STORED AS TEXTFILE;
不能使用parquet格式,否则数据导入为空,需要指定分隔符,指定存储格式;
将c.txt文件加载到hive表CompanyCode中,
load data local inpath '/home/hadoop/c.txt' into table CompanyCode;