北京市政百姓信件分析--数据清洗
-- 建表
create table xingfang(
kind string,
`time` string,
processingDepartment string,
content string
)
row format delimited fields terminated by ',';
-- 数据导入
load data local inpath '/home/onesec/xinfang_data.csv' into table xingfan
-- 每年的信件数量 统计和导出
insert overwrite local directory '/home/onesec/result1.csv'
row format delimited fields terminated by ','
stored as textfile
select year(replace(`time`,'/','-')) year,count(*) cnt from xingfang group by year(replace(`time`,'/','-'))
-- 信件种类及数量 统计和导出
insert overwrite local directory '/home/onesec/result2.csv'
row format delimited fields terminated by ','
stored as textfile
select kind,count(*) cnt from xingfang group by kind;
-- 政府部门及处理数量的信件数量 统计和导出
insert overwrite local directory '/home/onesec/result3.csv'
row format delimited fields terminated by ','
stored as textfile
select replace(processingDepartment,'"',""),count(*) cnt from xingfang group by replace(processingDepartment,'"',"");
本文作者:清梦韶华
本文链接:https://www.cnblogs.com/gnn40036/p/17474218.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步