[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>如何用shell脚本判断hive数据库是否导入dt分区的数据?
目标:将goals中所有的表名判断一遍,是否在hive的ods层中
tmp="part-" # 这里只取了"part-"这个字段 #遍历文本文件,获取表名称 for i in `cat /home/goals.txt` do
#获取hdfs上的以dt为时间分区的内容 temp1=`hadoop fs -ls /idp/src/ods/${i}/dt=$1`
#判断是否为空:这里用了grep来找出temp1字符串中是否有tmp("part-")这个子串 result=$(echo $temp1 | grep
"${temp0}") #创建每天执行任务的日志 cd /date touch $1.txt #判断是否有当日数据,都将结果输入创建的日志里 if [[
"$result" != "" ]] then echo "是" >> $1.txt else echo "否" >> $1.txt fi done
<>如何用python去除文件目录下所有文件的首行?
1.为何使用python去除?shell脚本同样能实现,看具体的需求,shell适合单个文件,python便于遍历整个文件夹。
2.如何使用删除首行功能?搭积木式,将搜索到的遍历功能和删除首行功能放在一起。
#conding=utf8 import fileinput import os # 获取目录下的全部文件 g = os.walk(r"/test") for
path,dir_list,file_list in g: for file_name in file_list: join = os.path.join(
path, file_name) #逐个删除文件的第一行 for line in fileinput.input(join, inplace=1): if
not fileinput.isfirstline(): print(line.replace('\n',''))
总结:我们在面对工作中编写程序的挑战,1.可以先试着完善功能,比如借鉴网络上其他人的实现方式。2.实现单个的测试,完成后再去做批量操作。3.最后再思考能否继续进一步优化。总之,我们采用小步快跑的方式完成开发挑战。