pip install openpyxl
1. 엑셀 활성화
from openpyxl import Workbookwb = Workbook()
ws = wb.active
엑셀을 활성화 하고
시트를 활성화함
2. 폴더에서 파일 읽기
for file in os.listdir('경로') :if file.endswith('.txt') :
f = open(file, 'rt', encoding='utf8')
경로에 있는 파일을 읽음
파일 중에 .txt로 끝나는 파일
파일을 읽음
3. 텍스트 파일에서 한줄씩 읽기
while True :line = f.readline()
if not line : break
4. 읽은 값 엑셀에 작성
for i in 배열 :ws['A'+str(c)]=i
c=c+1
wb.save('result.xlsx')