Python爬虫数据处理,字节跳动高级前端面试

1.3、 replace() 函数 和length()函数组合

set @address=‘中国-山东省-聊城市-莘县’; select @address ,replace(@address,‘-’,‘’) as address_1 ,length(@address) as len_add1 ,length(replace(@address,‘-’,‘’)) as len_add2 ,length(@address)-length(replace(@address,‘-’,‘’)) as _count

etl清洗字段时候有明显分割符的如何确定新的数据表增加几个分割出的字段

计算出com_industry中最多有几个 - 符 以便确定增加几个字段 最大值+1 为可以拆分成的字段数 此表为3 因此可以拆分出4个行业字段 也就是4个行业等级

select max(length(com_industry)-length(replace(com_industry,‘-’,‘’))) as _max_count

from etl1_socom_data

1.4、设置变量 substring_index()字符串截取函数用法

set @address=‘中国-山东省-聊城市-莘县’;

select

substring_index(@address,‘-’,1) as china,

substring_index(substring_index(@address,‘-’,2),‘-’,-1) as province,

substring_index(substring_index(@address,‘-’,3),‘-’,-1) as city,

substring_index(@address,‘-’,-1) as district

1.5、条件判断函数 case when

case when then when then else 值 end as 字段名

select case when 89>101 then ‘大于’ else ‘小于’ end as betl1_socom_data

二、kettle转换etl1清洗

================

首先建表 步骤在视频里

字段索引 没有提 索引算法建议用BTREE算法增强查询效率

2.1.kettle文件名:trans_etl1_socom_data

2.2.包括控件:表输入>>>表输出

2.3.数据流方向:s_socom_data>>>>etl1_socom_data

kettle转换1截图

2.4、表输入2.4、SQL脚本 初步清洗com_district和com_industry字段

select a.*, case when com_district like ‘%业’ or com_district like ‘%织’ or com_district like ‘%育’ then null else com_district end as com_district1 ,case when com_district like ‘%业’ or com_district like ‘%织’ or com_district like ‘%育’ then concat(com_district,‘-’,com_industry) else com_industry end as com_industry_total ,replace(com_addr,‘地 址:’,‘’) as com_addr1 ,replace(com_phone,‘电 话:’,‘’) as com_phone1 ,replace(com_fax,‘传 真:’,‘’) as com_fax1 ,replace(com_mobile,‘手机:’,‘’) as com_mobile1 ,replace(com_url,‘网址:’,‘’) as com_url1 ,replace(com_email,‘邮箱:’,‘’) as com_email1 ,replace(com_contactor,‘联系人:’,‘’) as com_contactor1 ,replace(com_emploies_nums,‘公司人数:’,‘’) as com_emploies_nums1 ,replace(com_reg_capital,‘注册资金:万’,‘’) as com_reg_capital1 ,replace(com_type,‘经济类型:’,‘’) as com_type1 ,replace(com_product,‘公司产品:’,‘’) as com_product1 ,replace(com_desc,‘公司简介:’,‘’) as com_desc1 from s_socom_data as a

select a.*, case #行业为’‘的值 置为空 when length(com_industry)=0 then null #其他的取第一个-分隔符之前 else substring_index(com_industry,’-‘,1) end as com_industry1, case when length(com_industry)-length(replace(com_industry,’-‘,’‘))=0 then null #‘交通运输、仓储和邮政业-’ 这种值 行业2 也置为null when length(com_industry)-length(replace(com_industry,’-‘,’‘))=1 and length(substring_index(com_industry,’-‘,-1))=0 then null when length(com_industry)-length(replace(com_industry,’-‘,’‘))=1 then substring_index(com_industry,’-‘,-1) else substring_index(substring_index(com_industry,’-‘,2),’-‘,-1) end as com_industry2, case when length(com_industry)-length(replace(com_industry,’-‘,’‘))<=1 then null when length(com_industry)-length(replace(com_industry,’-‘,’‘))=2 then substring_index(com_industry,’-‘,-1) else substring_index(substring_index(com_industry,’-‘,3),’-‘,-1) end as com_industry3, case when length(com_industry)-length(replace(com_industry,’-‘,’‘))<=2 then null else substring_index(com_industry,’-',-1) end as com_industry4 from etl1_socom_data as a

四、清洗效果质量检查

==========

4.1爬虫数据源数据和网站数据是否相符


如果本身工作是爬虫和数据处理在一起处理,抓取的时候其实已经判断,此步骤可以省略,如果对接上游爬虫同事,这一步首先判断,不然清洗也是无用功,一般都要求爬虫同事存储请求的url便于后面数据处理查看数据质量

4.2计算爬虫数据源和各etl清洗数据表数据量


注:SQL脚本中没有经过聚合过滤 3个表数据量应相等

4.2.1、sql查询 下面表我是在同一数据库中 如果不在同一数据库 from 后面应加上表所在的数据库名称

不推荐数据量大的时候使用

select count(1) from s_socom_data

union all

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Python开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img



既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Python开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注Python)
img

现在能在网上找到很多很多的学习资源,有免费的也有收费的,当我拿到1套比较全的学习资源之前,我并没着急去看第1节,我而是去审视这套资源是否值得学习,有时候也会去问一些学长的意见,如果可以之后,我会对这套学习资源做1个学习计划,我的学习计划主要包括规划图和学习进度表。

分享给大家这份我薅到的免费视频资料,质量还不错,大家可以跟着学习

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
img

2604bd33c4b6713f686ddd3fe5aff.png)

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
[外链图片转存中…(img-87nUnMjE-1712710340766)]

  • 25
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值