python历史5分钟数据_python实现某天每5分钟提取一条数据

from elasticsearch import Elasticsearch import os es = Elasticsearch(['localhost'], http_auth=('', ''), port=9273, timeout=50000) def write_start_data(time_, time_list, month, file_name, iptvaccount): write_fact_path = "E:\\公司\\案例数据采集\\olt告警案例分析\\{0}\\{1}_{2}.txt".format(time_, iptvaccount, file_name) f = open(write_fact_path, "w") for key, value in time_list.items(): start = key.format(day, start_hour, month, end_hour) end = value.format(day, start_hour, month, end_hour) hour_min = start.split()[1] if hour_min == "23:55": end = value.format(day_next,start_hour,month,end_hour) rs = get_iptv_monitor_start_data(time_, start, end, iptvaccount) for hit in rs['hits']['hits']: if __name__ == '__main__': time_ = "20180719" month = "07" day = "19" day_next = "20" hour_dict = {} for i in range(0, 24): if i < 10: str_i = "0" + str(i) str_j = "0" + str(i + 1) if str_j == "010": str_j = str(i + 1) hour_dict.setdefault(str_i, str_j) else: str_i = str(i) str_j = str(i + 1) if str_j == "24": str_j = "00" hour_dict.setdefault(str_i, str_j) for start_hour,end_hour in hour_dict.items(): time_list = {"2018-{2}-{0} {1}:00": "2018-{2}-{0} {1}:05", "2018-{2}-{0} {1}:05": "2018-{2}-{0} {1}:10", "2018-{2}-{0} {1}:10": "2018-{2}-{0} {1}:15", "2018-{2}-{0} {1}:15": "2018-{2}-{0} {1}:20", "2018-{2}-{0} {1}:20": "2018-{2}-{0} {1}:25", "2018-{2}-{0} {1}:25": "2018-{2}-{0} {1}:30", "2018-{2}-{0} {1}:30": "2018-{2}-{0} {1}:35", "2018-{2}-{0} {1}:35": "2018-{2}-{0} {1}:40", "2018-{2}-{0} {1}:40": "2018-{2}-{0} {1}:45", "2018-{2}-{0} {1}:45": "2018-{2}-{0} {1}:50", "2018-{2}-{0} {1}:50": "2018-{2}-{0} {1}:55", "2018-{2}-{0} {1}:55": "2018-{2}-{0} {3}:00", } path = "E:\\公司\\案例数据采集\\olt告警案例分析\\{0}".format(time_) if os.path.exists(path): pass else: os.makedirs(path) write_start_data(time_, time_list, month, start_hour, iptv) # 获取原始数据

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值