Python制作数据导入导出工具

python 2.6编写,自己瞎写的,备用

'''  Export and Import ElasticSearch Data.  Simple Example At __main__  @author: wgzh159@163.com  @note: uncheck consistency of data, please do it by self''' import jsonimport osimport sysimport timeimport urllib2 reload(sys)sys.setdefaultencoding('utf-8') # @UndefinedVariable class exportEsData():  size = 10000  def __init__(self, url,index,type):    self.url = url+"/"+index+"/"+type+"/_search"    self.index = index    self.type = type  def exportData(self):    print("export data begin...")    begin = time.time()    try:      os.remove(self.index+"_"+self.type+".json")    except:      os.mknod(self.index+"_"+self.type+".json")    msg = urllib2.urlopen(self.url).read()    print(msg)    obj = json.loads(msg)    num = obj["hits"]["total"]    start = 0    end = num/self.size+1    while(start

以上所述就是本文的全部内容了,希望大家能够喜欢。

登录后复制

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2300874.html

(0)
上一篇 2025年2月28日 04:57:11
下一篇 2025年2月26日 04:05:36

AD推荐 黄金广告位招租... 更多推荐

相关推荐

发表回复

登录后才能评论