import pandas as pd import re from xlrd import open_workbook INFILE='Анонсы_Старт.xls' INFILE='Анонсы_Триумф.xls' with open_workbook(INFILE) as wb: chanel=wb[0][0,2].value df=pd.read_excel(INFILE,header=1) for i,row in df.iterrows(): title=row.at['Title'] title=re.sub(r'\(.+?\)','',title) m=re.match(r'(?:Прямой эфир.)?\s*([^\.]+)\.\s*(.+)\.\s*([^\.]+?)\s*-\s*([^\.]+?)\s*\.',title) if m: #print(title) sport,league,team_a,team_b = m.groups() r={'date':row.at['Date'],'time':row.at['Start Time'], 'chanel':'START' if chanel=='Старт' else 'TRIUMPH', 'sport':sport,'league':league, 'team_a':team_a,'team_b':team_b} print(r) else: print(title)