Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
739 B
2
Indexable
Never
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")
Leave a Comment