在这个案例中,我们要实现的是统计每个用户(以手机号作为用户标识)过去几个月分别在数码、出行、餐饮方面的支出之和,也就是将每个月的数码支出进行求和,出行支出求和,餐饮方面求和,最后得出3个值。
- 准备数据
将数据上传至服务器:
[root@hadoop01 test_data]# cat test_shopping.txt
15525535555,03,2890,437,1495
16626636666,05,1264,308,1677
16626636666,03,530,259,2174
15525535555,05,1088,372,1726
16626636666,04,754,417,1586
将数据文件上传至HDFS:
[root@hadoop01 test_jar]# hdfs dfs -mkdir /test_shopping_input
[root@hadoop01 test_jar]# cd ../
[root@hadoop01 hadoop-2.7.5]# cd ../test_data/
[root@hadoop01 test_data]# hdfs dfs -put test_shopping.txt /test_shopping_input