[英]How does python read the content of txt file and save it in excel
in one folder, there are two files a.txt b.txt在一个文件夹中,有两个文件 a.txt b.txt
a.txt has data, a111 a222 a333 a.txt有数据,a111 a222 a333
b.txt has data, b111 b222 b333 b.txt有数据,b111 b222 b333
I want their data to save into the excel file one column我要他们的数据保存到excel文件一栏
Something like this:是这样的:
from openpyxl import load_workbook
from openpyxl import Workbook
wb = load_workbook(filename = "your.xlsx")
ws = wb.activewith
row1 = 1
open("demo.txt") as file:
for item in file:
ws.cell(row=row1, column=1).value = item
row1 = row1 + 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.