0
Pythonを使用して、ディレクトリ内のすべての.xlsファイルを1つのデータフレームにマージし、新しい連結.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