0
파이썬을 사용하여 디렉토리의 모든 .xls 파일을 하나의 데이터 프레임으로 병합하고이를 새로운 연결 .xls 파일로 저장하려고합니다. .xls 파일에는 알 수없는 열 수와 일관된 헤더가 없습니다.알 수없는 열 수를 가진 여러 .xls 파일 연결
나는 이것으로이 포럼에 다른 제안을 사용하고 결국했습니다
import os
import pandas as pd
path = os.getcwd()
files = os.listdir(path)
files_xls = [f for f in files if f[-3:] == 'xls']
df = pd.DataFrame()
for f in files_xls:
data = pd.read_excel(f for f in files_xls) # I dont understand what to add
# in the parentheses here.
df = df.append(data)
df
내가 갖는 이러한 오류 :
File "<ipython-input-17-bb67a423cf40>", line 14, in <module>
data = pd.read_excel(f for f in files_xls)
File "C:\Users\xxxx\Anaconda2\lib\site-packages\pandas\io\excel.py", line 170, in read_excel
io = ExcelFile(io, engine=engine)
File "C:\Users\xxxx\Anaconda2\lib\site-packages\pandas\io\excel.py", line 229, in __init__
raise ValueError('Must explicitly set engine if not passing in'
ValueError: Must explicitly set engine if not passing in buffer or path for io.
Noobie 시도 , 그것을 시도, 남자. 작동하지 않았어, 완전히 새로운 에로스. – BioProg
그 부분까지 작동 –
files_xls의 출력을 보여 아웃 [20] [ '20161220_VAMP2_mCherry_cell1.xls' '20161220_VAMP2_mCherry_cell10.xls' '20161220_VAMP2_mCherry_cell2.xls' '20161220_VAMP2_mCherry_cell4.xls' '20161220_VAMP2_mCherry_cell5 .xls ', '20161220_VAMP2_mCherry_cell8.xls ', '20161220_VAMP2_mCherry_cell9.xls '] – BioProg