Skip to content

Latest commit

 

History

History
76 lines (47 loc) · 2.19 KB

Excel_Consolidate_files.md

File metadata and controls

76 lines (47 loc) · 2.19 KB



Template request | Bug report | Generate Data Product

Tags: #excel #pandas #read #save #naas #asset #finance #snippet

Author: Florent Ravenel

Description: This notebook provides a comprehensive guide to consolidating multiple Excel files into one.

Input

Import libraries

import pandas as pd
import naas

Variables

# Input
excel_file_path1 = "Excel-Sales_Jan2020.xlsx"
excel_file_path2 = "Excel-Sales_Jan2020.xlsx"

# Output
excel_output_path = "Conso.xlsx"

Model

Read the 2 Excel files

You want to add more parameters ?
👉 Check out the pandas documentation here.

df1 = pd.read_excel(excel_file_path1)
df1
df2 = pd.read_excel(excel_file_path2)
df2

Consolidate Excel

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

Output

Save dataframe to Excel

You want to add more parameters ?
👉 Check out the pandas documentation here.

df_concat.to_excel(excel_output_path)
print(f'💾 Excel '{excel_output_path}' successfully saved in Naas.')

Share excel with Naas

naas.asset.add(excel_output_path)