Untitled

 avatar
unknown
plain_text
a year ago
739 B
4
Indexable
import openpyxl

# Read the input string from a file
with open("D:\\Pro\\Cpp\\CollectWords\\input.txt", "r", encoding='utf-8') as f:
    input_strings = f.readlines()

# Process each input string separately
for input_string in input_strings:
    # Split the string into individual cells
    cells = input_string.split("|")

    # Remove empty cells
    cells = [cell.strip() for cell in cells if cell.strip()]

    # Create a new Excel workbook and worksheet
    wb = openpyxl.Workbook()
    ws = wb.active
    
    # Write the cells to the worksheet
    for i, cell in enumerate(cells):
        ws.cell(row=1, column=i+1).value = cell

    # Save the workbook
    wb.save(f"D:\\Pro\\Cpp\\CollectWords\\output.xlsx")
Editor is loading...
Leave a Comment