# Write a program to read in the contents of several text files (you can make
# the text files yourself) and insert those contents into a spreadsheet, with
# one line of text per row. The lines of the first text file will be in the
# cells of column A, the lines of the second text file will be in the cells of
# column B, and so on.

import openpyxl

# Open workbook
wb = openpyxl.Workbook()
sheet = wb.active

# Get list of files

# Open file

# Scan lines into list

# Transpose list into relevant workbook column

# Close file

# Save workbook
wb.save("textToExcel.xlsx")

# Write a program to read in the contents of several text files (you can make
# the text files yourself) and insert those contents into a spreadsheet, with
# one line of text per row. The lines of the first text file will be in the
# cells of column A, the lines of the second text file will be in the cells of
# column B, and so on.

import openpyxl
import os

FOLDER = "./p4files/"

# Open workbook
wb = openpyxl.Workbook()
sheet = wb.active

# Get list of files
filelist = os.listdir(FOLDER)
filelist.sort()

# Open file
for file in filelist:
    with open(FOLDER + file) as fileObj:
        index = 1
        for line in fileObj:
            # Transpose line into relevant workbook column
            sheet.cell(row=index, column=(filelist.index(file) + 1)).value = line.strip()
            index += 1

# Save workbook
wb.save("textToExcel.xlsx")

Update P4_textToExcel working solution