I am trying to rename tabs in an excel spreadsheet however it for one of the tabs it produces this name every time: '# of Behavioral Health Reps (5)1' Not sure why. There is only 1 of these matching tabs in each file. It also does not do it to any other tab.
text_search = pd.DataFrame(
{'text_to_search':
[
'Retro'
,'Prior'
,'Concurr'
,'Rate'
,'claims pd'
,'health reps'
,'External']
,
'Replace':
[
'UR - Retrospective (1)'
,'UR - Prior Auth Req (2)'
,'UR - Concurrent Auth Req (2)'
,'Rate of First Level Appeals (3)'
,'Pct of Claims Paid (4)'
,'# of Behavioral Health Reps (5)'
,'External Appeals (9)']})
for mco in files:
wb = xl.load_workbook(mco, data_only=True)
for sheet in wb.sheetnames:
for index, row in text_search[0:].iterrows():
#print(row['text_to_search'],row['Replace'])
if re.search(row['text_to_search'], sheet, re.IGNORECASE):
worksheet = wb[sheet]
worksheet.title = row['Replace']
wb.save(mco)
wb.close()```