# df라는 dataframe에 file1의 dataframe을 아래로 쭉 이어 붙이는 함수
df=df.append(file1, ignore_index=True)
# 여러개 엑셀 파일 열기 후 하나의 파일로 통합하여 저장
import pandas as pd
import numpy as np
import xlrd
import os
from xlrd import open_workbook
PO = ['91125','91125','91209','91209','91216','91224','9122S','200106','200106','200114','200114','200120','200120',
'200127','200127W','200203','200203W','200217E','200217','200320','200320','200330','200330','200420','200420',
'200504','200522','200522','200529','200529','200605','200601','200602','200602','200617','200617','200627','200623',
'200624','200624','20211','20211','200323','200323','200712','200712']
df=pd.DataFrame(dtype='string')
for i in PO:
file=open_workbook("C:\\Users\\me\\desktop\\data\\0828\\LPN_{}(IN).xlsx".format(i), logfile=open(os.devnull, 'w'))
file1=pd.read_excel(file, engine='xlrd',dtype={'FULL LPN#':str})
df=df.append(file1, ignore_index=True)
df.to_excel('total_0831.xlsx') #모든 PO를 1개 파일로 통합 완료.
'Python' 카테고리의 다른 글
파이썬_선택한 row 원하는 개수만큼 복사,추가하기 (0) | 2020.11.06 |
---|---|
파이썬_한 칼럼 내 모든 데이터에 동일한 문자열 추가 (0) | 2020.11.03 |
파이썬_칼럼 내 문자열 분할 (5번째부터 9번째까지만 끊어 저장) (0) | 2020.11.03 |
파이썬_여러 칼럼의 데이터를 한 칼럼으로 붙여넣기 (엑셀 &기능) (0) | 2020.11.03 |
파이썬_리스트에 포함된/포함되지 않은 데이터만 추출 (필터링) (0) | 2020.11.03 |