pip install python-Levenshtein

from openpyxl import Workbook
import xlrd
import time
import Levenshtein as Le target_city_list = []
file_name = 'DB任务_csv_py_wholeCSV-加百度170825095914'
FEXCEL = '%s%s' % (file_name, '.xlsx')
data = xlrd.open_workbook(FEXCEL)
table = data.sheets()[0]
nrows, ncols = table.nrows, table.ncols
wb = Workbook()
worksheet = wb.active
file_title_str = 'dbid, area_code, ref_area_type_code, city, district, address, city_street, name_, BDpoi_list, BD_name, BD_addr, seqratio_res'
file_title_l = file_title_str.replace(' ', '').split(',')
worksheet.append(file_title_l)
BDpoi_list_tag, BDpoi_list_tagb = '|-|', '|--|'
for i in range(0, nrows):
l = table.row_values(i)
dbid, area_code, ref_area_type_code, city, district, address, city_street, name_, BDpoi_list = l
if dbid == 'dbid':
continue
addr_ = '%s%s%s%s' % (city, district, address, city_street)
chk_name_lsit,cmp_list,sorted_seqratio_res_dic = [name_,addr_],BDpoi_list.split(BDpoi_list_tag),{}
for ii in cmp_list:
cmp_, BD_name, BD_addr = ['', ''], '', ''
cmp_one = ii.split(BDpoi_list_tagb)
if len(cmp_one) == 2:
BD_name, BD_addr = cmp_[0], cmp_[1] = cmp_one
else:
BD_name = cmp_[0] = cmp_one[0]
seqratio_res = Le.seqratio(chk_name_lsit, cmp_)
ll = dbid, area_code, ref_area_type_code, city, district, address, city_street, name_, BDpoi_list, BD_name, BD_addr, seqratio_res
if seqratio_res not in sorted_seqratio_res_dic:
sorted_seqratio_res_dic[seqratio_res] = []
sorted_seqratio_res_dic[seqratio_res].append(ll) sorted_seqratio_res_list = sorted(sorted_seqratio_res_dic) for seqratio_res in sorted_seqratio_res_list:
lll = sorted_seqratio_res_dic[seqratio_res]
for vl in lll:
worksheet.append(vl) localtime_ = time.strftime("%y%m%d%H%M%S", time.localtime())
file_name = '%s%s%s' % (file_name,'-Levenshtein',localtime_)
file_name_save = '%s%s' % (file_name, '.xlsx')
wb.save(file_name_save)

  

最新文章

  1. C++ 画星号图形——空心三角形(星号左对齐)(核心代码介绍)
  2. SQL关于分页的sql查询语句 limit 和row_number() OVER函数
  3. PHP历程(封装的增删改查方法)
  4. Hadoop:Windows 7 32 Bit 编译与运行
  5. 解惑:NFC手机如何轻松读取银行卡信息?
  6. nodejs的调试(node-inspector)
  7. java 读取图片色深
  8. IIS与ASP.NET对请求的处理
  9. 监控报I/O问题,怎么办?
  10. css美化页面
  11. MarkDown基础语法记录
  12. Elasticsearch 系列4 --- Windows10安装Kibana
  13. win7游戏窗口设置
  14. python及扩展程序安装
  15. 机器学习理论基础学习13--- 隐马尔科夫模型 (HMM)
  16. Java之集合(一)接口及抽象类
  17. 触发器 视图 存储过程 mysql常用函数
  18. xdebug和最重要的php调试技巧
  19. curl工具
  20. oracle 11g各种下载地址

热门文章

  1. JWT笔记
  2. [WCF菜鸟]什么是WCF
  3. SSO单点登录系列5:cas单点登录增加验证码功能完整步骤
  4. 7. JPA - Hibernate【从零开始学Spring Boot】
  5. MySQL高可用解决方案MMM
  6. How to check the 'OLE DB Destination' INPUT and OUTPUT
  7. Android学习(十九)Dialog对话框
  8. redis中的事务(版本2.6.16)
  9. Laravel请求/Cookies/文件上传
  10. 【Excle数据透视表】如何水平并排显示报表筛选区域的字段