Consolidate files
Tags: #excel #pandas #read #save #naas #asset
Author: Florent Ravenel

Input

Import libraries

1
import pandas as pd
2
import naas
Copied!

Variables

1
# Input
2
excel_file_path1 = "Excel-Sales_Jan2020.xlsx"
3
excel_file_path2 = "Excel-Sales_Jan2020.xlsx"
4
5
# Output
6
excel_output_path = "Conso.xlsx"
Copied!

Model

Read the 2 Excel files

You want to add more parameters ? 👉 Check out the pandas documentation here.
1
df1 = pd.read_excel(excel_file_path1)
2
df1
Copied!
1
df2 = pd.read_excel(excel_file_path2)
2
df2
Copied!

Consolidate Excel

1
df_concat = pd.concat([df1, df2], axis=0).reset_index(drop=True)
2
df_concat
Copied!

Output

Save dataframe to Excel

You want to add more parameters ? 👉 Check out the pandas documentation here.
1
df_concat.to_excel(excel_output_path)
2
print(f'💾 Excel '{excel_output_path}' successfully saved in Naas.')
Copied!

Share excel with Naas

1
naas.asset.add(excel_output_path)
Copied!
Copy link
Edit on GitHub