hive实例-乘用车辆和商用车辆销售数据分析

本文通过实例展示了如何使用Hive进行乘用车和商用车辆销售数据分析。首先,从指定数据源获取Excel数据,将其转换为car.txt文件并设置为UTF-8编码。接着,创建名为car的Hive数据库,并在其中建立相应的表结构,最后将数据上传到Hive表中进行分析。
摘要由CSDN通过智能技术生成

数据源地址:http://pan.baidu.com/s/1cKsrKi

1.准备数据源

打开 上牌数--商用车销量数据样例.xlsx,另存为car.txt文件,打开car.txt,设置编码格式为UTF-8,保存并上传至master节点。

2.创建car 数据库,建立car表,并上传数据

create external table cars(
province string, --省份
month int, --月
city string, --市 
county string, --区县
year int, --年
cartype string,--车辆型号
productor string,--制造商
brand string, --品牌
mold string,--车辆类型
owner string,--所有权
nature string, --使用性质
number int,--数量
ftype string,--发动机型号
outv int,--排量
power double, --功率
fuel string,--燃料种类
length int,--车长
width int,--车宽
height int,--车高
xlength int,--厢长
xwidth int,--厢宽
xheight int,--厢高
count int,--轴数
base int,--轴距
front int,--前轮距
norm string,--轮胎规格
tnumber int,--轮胎数
total int,--总质量
curb int,--整备质量
hcurb int,--核定载质量
passenger string,--核定载客
zhcurb int,--准牵引质量
business string,--底盘企业
dtype string,--底盘品牌
fmold string,--底盘型号
fbusiness string,--发动机企业
name string,--车辆名称
age int,--年龄
sex string --性别
)
row format delimited
fields terminated by '\t'
location '/cars';
使用以下命令为cars表导入数据,并查看导入是否成功:
hive> load data local inpath 'car.txt' into table cars;
Loading data to table car.cars
Table car.cars stats: [numFiles=0, totalSize=0]
OK
Time taken: 1.244 seconds
hive> select * from cars limit 2;
OK
山西省 3 朔州市
  • 2
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值