In excell i have a column which contains several words. For my program I need only first one (and only letters). For example, cell -'dog,dogge', but we need only 'dog'.
I made the programm but the form of output is very strange. Need your help what to change.
My code:
I made the programm but the form of output is very strange. Need your help what to change.
My code:
import openpyxl import re source_file=openpyxl.load_workbook((r’C:\Users\user\Desktop\Питон\Слова_английский.xlsx’)) first_sheet = source_file.worksheets[0] #активный первый лист column_b = first_sheet[‘B’] #столбец B for i in range(len(column_b)): keyRegex = re.compile(r'([а-яА-Я ]+)’) column_b_correct = keyRegex.search(str(column_b[i].value)) print(column_b_correct)I have the result:
Output:<re.Match object; span=(0, 7), match=’реклама’>
<re.Match object; span=(0, 6), match=’комикс’>
<re.Match object; span=(0, 6), match=’беседа’>
But I need only the words itself:Output:реклама
комикс
беседа