0

I have a lots of excel files +200, all of these have the same format.

the directorys are saved in this list

dir_list = ['all','files]

I want to convert all of them into one single df

below is what I want to select from each excel file into the new df

used_col = ['Dimension', 'Length','Customer']


df_x = pd.read_excel(file,sheet_name='Tabelle1',skiprows=3,skipinitialspace=True, usecols=used_col)

how can I do that ?

rpanai
  • 12,515
  • 2
  • 42
  • 64
  • Possible duplicate of [Import multiple csv files into pandas and concatenate into one DataFrame](https://stackoverflow.com/questions/20906474/import-multiple-csv-files-into-pandas-and-concatenate-into-one-dataframe) – rpanai Nov 07 '19 at 13:10

1 Answers1

1

You are close, you need to use concat to create a single df from all files.

tmp = [] 
used_col = ['Dimension', 'Length','Customer']
for file in dir_list:
      df_x = pd.read_excel(file,sheet_name='Tabelle1',skiprows=3,skipinitialspace=True, usecols=used_col)
       tmp.append(df_x)
final_df = pd.concat(tmp)
Florian Bernard
  • 2,561
  • 1
  • 9
  • 22