Perhaps not the most efficient implementation, but an easy one:
import openpyxl wb = openpyxl.Workbook() sheet_counter = 1 # You should consider adopting better conventions such as these ones: SHEET_SEPARATOR = "===" COLUMN_SEPARATOR = '|' with open('text.txt', 'r+') as raw_text: lines = raw_text.read().split(SHEET_SEPARATOR) for line in lines: rows = line.split('\n') ws = wb.create_sheet(f'Sheet{sheet_counter}') for row in rows: ws.append(row.split(COLUMN_SEPARATOR)) wb.save('result.xlsx') sheet_counter += 1 wb.save('result.xlsx')