This code below read .txt files and print the results, but I need save the results as .xlsx, I searched the internet but I didn't get any solution, can someone help me?
import os
path = input('Enter Directory:')
os.chdir(path)
def read_text_file(file_path):
with open(file_path, 'r') as f:
print(f.read())
for file in os.listdir():
if file.endswith(".txt"):
file_path = f"{path}\{file}"
read_text_file(file_path)
the data format in .txt files is like this:
"174125_1.jpg"
"174127_1.jpg"
"174128_1.jpg"
"174129_1.jpg"
"174130_1.jpg"
"176475_1.jpg"
"178836_1.jpg"
"179026_1.jpg"
"179026_2.jpg"
"179026_3.jpg"
"179026_4.jpg"
"179026_5.jpg"
them are registration data from images uploaded to an e-commerce.