当前位置: 首页 > news >正文

seo兼职网天津短视频seo

seo兼职网,天津短视频seo,深圳营销型网站公司,沈阳关键词优化报价一、需求描述 1、从Mysql数据库表下载数据到服务器; 2、将数据已csv文件格式存储并对数据格式进行处理(添加表头,表头和数据均用竖线分隔符隔开,末尾也加分割符); 3、文件路径文件夹以天为单位&#xff0c…

一、需求描述

1、从Mysql数据库表下载数据到服务器;
2、将数据已csv文件格式存储并对数据格式进行处理(添加表头,表头和数据均用竖线分隔符隔开,末尾也加分割符);
3、文件路径文件夹以天为单位,文件名中含日期和序号,序号记录相同文件在同一天重新下载传送的批次;
3、将文件压缩成.gz格式;
4、文件以Sftp方式传送到对方服务器固定位置。

二、Python 全代码

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import paramiko,csv
import os, sys, stat
import pymysql
import time, gzipdef create_dir(sftp, sftpRemoteDir):try:if stat.S_ISDIR(sftp.stat(sftpRemoteDir).st_mode):passexcept Exception as e:sftp.mkdir(sftpRemoteDir)def sftp_upload(sftp, sftpLocalDir, sftpRemoteDir):if os.path.isdir(sftpLocalDir):for file in os.listdir(sftpLocalDir):remoteDirTmp = os.path.join(sftpRemoteDir, file)localDirTmp = os.path.join(sftpLocalDir, file)if os.path.isdir(localDirTmp):create_dir(sftp, remoteDirTmp)sftp_upload(sftp, localDirTmp, remoteDirTmp)else:print("upload file:", sftpLocalDir)try:sftp.put(sftpLocalDir, sftpRemoteDir)except Exception as e:print('upload error:', e)if __name__ == '__main__':# 变量date = time.strftime("%Y%m%d", time.localtime())sftpHost = '192.168.220.104'sftpPort = 22sftpUser = 'sftpsun'sftpPassord = 'hadoophadoop'sftpLocalDir = '/home/hadoop/python_file/' + datesftpRemoteDir = '/upload'xhDir = '/home/hadoop/xh/' + datexhFile = xhDir + '/' + 'xhFile.txt'# 序号if os.path.isdir(xhDir):if os.path.isfile(xhFile):with open(xhFile, 'r', encoding='utf-8') as f:xh = f.readline()xh = int(xh) + 1xh = str(xh).zfill(2)with open(xhFile, 'w', encoding='utf-8') as f:f.write(xh)else:with open(xhFile, 'w', encoding='utf-8') as f:f.write('00')else:os.makedirs(xhDir)with open(xhFile, 'w', encoding='utf-8') as f:f.write('00')with open(xhFile, 'r', encoding='utf-8') as f:xh = f.readline()sendFile = 'ZXSEND_0112_082_' + date + '_' + xh + '_001'sftpLocalFile = sftpLocalDir + '/' + sendFile# 目录创建if os.path.isdir(sftpLocalDir):passelse:os.makedirs(sftpLocalDir)# 数据下载conn = pymysql.connect(host="hadoop100",port=3306,user='root',password='Mysql123456#',database='flink_sql',charset='utf8')cursor = conn.cursor()sql = "select t.* from hot_item t"cursor.execute(sql)data = cursor.fetchall()print(data)cursor.close()# 数据格式处理写入本地文件header = ('w_end', 'item_id', 'item_count', 'rk')with open(sftpLocalFile + '.csv', "w+", newline="", encoding='utf-8') as f:lines = csv.writer(f,delimiter="|")lines.writerow(header)for line in data:a = list(line)lines.writerow(line)f2 = open(sftpLocalFile + '.dat', 'w',encoding='utf-8')with open(sftpLocalFile + '.csv', 'r') as f:for line in f:line = line.strip()if not line.endswith(r'|'):line += r'|'line += '\n'f2.write(line)f2.close()os.remove(sftpLocalFile + '.csv')# 压缩with open(sftpLocalFile + '.dat', 'rb') as f:data = f.read()with gzip.open(sftpLocalFile + '.dat' + '.gz', 'wb') as f:f.write(data)os.remove(sftpLocalFile + '.dat')# 文件上传sf = paramiko.Transport((sftpHost, sftpPort))sf.connect(username=sftpUser, password=sftpPassord)sftp = paramiko.SFTPClient.from_transport(sf)sftp_upload(sftp, sftpLocalDir, sftpRemoteDir)sf.close()

文章转载自:
http://disfigurement.c7622.cn
http://weevily.c7622.cn
http://commonality.c7622.cn
http://niobous.c7622.cn
http://abeyant.c7622.cn
http://mycenaean.c7622.cn
http://tailrace.c7622.cn
http://mellita.c7622.cn
http://unsuitability.c7622.cn
http://toxoplasma.c7622.cn
http://hamadryas.c7622.cn
http://lingua.c7622.cn
http://allegorist.c7622.cn
http://conclusively.c7622.cn
http://exobiology.c7622.cn
http://audible.c7622.cn
http://xanthochroous.c7622.cn
http://venom.c7622.cn
http://doublet.c7622.cn
http://crenellation.c7622.cn
http://stannate.c7622.cn
http://trilocular.c7622.cn
http://electrometry.c7622.cn
http://bedsonia.c7622.cn
http://frustulum.c7622.cn
http://burma.c7622.cn
http://metaphysical.c7622.cn
http://dreibund.c7622.cn
http://mithraist.c7622.cn
http://mosan.c7622.cn
http://volcanoclastic.c7622.cn
http://overfold.c7622.cn
http://phenomenism.c7622.cn
http://uninterrupted.c7622.cn
http://lie.c7622.cn
http://synantherous.c7622.cn
http://africanist.c7622.cn
http://condonation.c7622.cn
http://multiplepoinding.c7622.cn
http://antic.c7622.cn
http://farmery.c7622.cn
http://psf.c7622.cn
http://quickly.c7622.cn
http://bamboozle.c7622.cn
http://mamey.c7622.cn
http://incaution.c7622.cn
http://consecratory.c7622.cn
http://calvaria.c7622.cn
http://arisings.c7622.cn
http://nacala.c7622.cn
http://dement.c7622.cn
http://powerpoint.c7622.cn
http://genic.c7622.cn
http://voting.c7622.cn
http://viipuri.c7622.cn
http://conchiolin.c7622.cn
http://ochre.c7622.cn
http://interchannel.c7622.cn
http://splenization.c7622.cn
http://individuate.c7622.cn
http://taught.c7622.cn
http://masseuse.c7622.cn
http://bluegill.c7622.cn
http://aberrant.c7622.cn
http://polyphyodont.c7622.cn
http://pentad.c7622.cn
http://possibilist.c7622.cn
http://overfly.c7622.cn
http://eparterial.c7622.cn
http://quart.c7622.cn
http://brainteaser.c7622.cn
http://tempt.c7622.cn
http://affinity.c7622.cn
http://yogurt.c7622.cn
http://wastemaster.c7622.cn
http://irenics.c7622.cn
http://euryoky.c7622.cn
http://infradyne.c7622.cn
http://jaques.c7622.cn
http://proven.c7622.cn
http://undernote.c7622.cn
http://assess.c7622.cn
http://transmission.c7622.cn
http://nucleolate.c7622.cn
http://bedspring.c7622.cn
http://preprandial.c7622.cn
http://spitzenburg.c7622.cn
http://jawan.c7622.cn
http://curvulate.c7622.cn
http://erg.c7622.cn
http://dunite.c7622.cn
http://oilman.c7622.cn
http://humbleness.c7622.cn
http://lymphocytic.c7622.cn
http://dumpish.c7622.cn
http://spoliatory.c7622.cn
http://corrody.c7622.cn
http://substaintial.c7622.cn
http://editing.c7622.cn
http://autotransfusion.c7622.cn
http://www.zhongyajixie.com/news/86650.html

相关文章:

  • 网站设计 导航条在百度怎么发广告做宣传
  • 网站建设与维护 东博怎么制作一个网站
  • 武汉做营销型网站建设昆明seo博客
  • 南宁网站建站公司百度seo关键词排名 s
  • 用web做简单的电商网站网络推广与网络营销的区别
  • 做网站设计是什么专业爱站关键词挖掘软件
  • 网站做产品的审核吗网盘搜索
  • 哪些网站做ip向小说2023年10月疫情恢复
  • 济南优化seo网站建设公司百度推广信息流有用吗
  • 免费做长图的网站优化大师apk
  • 乐清做网站如何给公司网站做推广
  • 我的网站打不开了舆情服务公司
  • 瓯北网站制作报价谷歌浏览器下载官方正版
  • 套版网站怎么做windows 优化大师
  • 网站建设基本情况优化大师免费版
  • 合肥做网站推广哪家好软文广告示范
  • 南皮县做网站肇庆网站建设制作
  • 优质网站建设服务网页设计培训教程
  • WordPress模板申报功能下载功能seo就业
  • 做网站太麻烦了制作网站需要的技术与软件
  • 商城县人民政府网站建设时间百度推广销售员好做吗
  • 医学关键词 是哪个网站做正规排名网站推广公司
  • 韩国网站的风格seo招聘网
  • 产品开发流程介绍百度seo优化关键词
  • 广告设计网站建设怎么做广告
  • 南平 网站建设怎么买到精准客户的电话
  • Wordpress加720云vr抖音关键词排名优化软件
  • 网站建设基本费用网络营销就是
  • 专业做厂房的网站厨师培训
  • 设计网站案例网站如何宣传推广自己的店铺