广告 竞价排名 import Levenshtein as Le seqratio_res = Le.seqratio(chk_name_lsit, cmp_)
2024-10-19 12:41:59
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)
最新文章
- C++ 画星号图形——空心三角形(星号左对齐)(核心代码介绍)
- SQL关于分页的sql查询语句 limit 和row_number() OVER函数
- PHP历程(封装的增删改查方法)
- Hadoop:Windows 7 32 Bit 编译与运行
- 解惑:NFC手机如何轻松读取银行卡信息?
- nodejs的调试(node-inspector)
- java 读取图片色深
- IIS与ASP.NET对请求的处理
- 监控报I/O问题,怎么办?
- css美化页面
- MarkDown基础语法记录
- Elasticsearch 系列4 --- Windows10安装Kibana
- win7游戏窗口设置
- python及扩展程序安装
- 机器学习理论基础学习13--- 隐马尔科夫模型 (HMM)
- Java之集合(一)接口及抽象类
- 触发器 视图 存储过程 mysql常用函数
- xdebug和最重要的php调试技巧
- curl工具
- oracle 11g各种下载地址
热门文章
- JWT笔记
- [WCF菜鸟]什么是WCF
- SSO单点登录系列5:cas单点登录增加验证码功能完整步骤
- 7. JPA - Hibernate【从零开始学Spring Boot】
- MySQL高可用解决方案MMM
- How to check the 'OLE DB Destination' INPUT and OUTPUT
- Android学习(十九)Dialog对话框
- redis中的事务(版本2.6.16)
- Laravel请求/Cookies/文件上传
- 【Excle数据透视表】如何水平并排显示报表筛选区域的字段