问题描述
writer = pd.ExcelWriter('data-{}.xlsx'.format(pd.datetime.today().strftime('%Y%m%d-%H%M%s')))
df1.to_excel(writer,'Sheet1',index = False)
#df2.to_excel(writer,'Sheet2',index = False)
writer.save()
projects = df['name'].unique().tolist()
processedProjects = []
matchers = []
threshold_ratio = 60
for project in projects:
if project:
processedProject = fuzz._process_and_sort(project,True,True)
processedProjects.append(processedProject)
matchers.append(fuzz.SequenceMatcher(None,processedProject))
today_string = datetime.today().strftime('%Y%m%d-%H%M%s')
with open('data-' + today_string + '.csv','w') as f1:
writer = csv.writer(f1,delimiter = ',',lineterminator = '\n',)
writer.writerow(('name','name_','ratio'))
for project1,project2 in itertools.combinations(enumerate(processedProjects),2):
matcher = matchers[project1[0]]
matcher.set_seq2(project2[1])
ratio = int(round(100 * matcher.ratio()))
if ratio >= threshold_ratio:
#print(projects[project1[0]],projects[project2[0]])
my_list = projects[project1[0]],projects[project2[0]],ratio
print(my_list)
writer.writerow(my_list)
如何将Sheet2
附加到data-{}.xlsx
中,而不是编写名为'data-' + today_string + '.csv'
的csv文件。
感谢您的提前帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)