Merging excel sheets can be pretty tough and also many source ask for money to merge sheets. You can merge two excel sheets for free with this method.
First search google colab in search engine or go to https://colab.research.google.com/. Click in new notebook and paste the following code.
- Importing the necessary dependencies.
import pandas as pd
from google.colab import drive,files
drive.mount('/content/drive') - Give the path to the both sheet you want to merge. First paste first_sheet and second_sheet inside Colab Notebooks in your drive.
f1=pd.read_csv(r'/content/drive/My Drive/Colab Notebooks/first_sheet.csv', low_memory=False,encoding= 'unicode_escape')
f2=pd.read_csv(r'/content/drive/My Drive/Colab Notebooks/second_sheet.csv', low_memory=False,encoding= 'unicode_escape') - Replace primary_key with the key with which you want to merge the sheets.
df = f1.merge(f2, on = "primary_key",how = "outer") - Saving the merged file with the name Result.csv
df.to_csv(r"Results.csv")
files.download('Results.csv')
Here’s the full code for merging two spreadsheet.
import pandas as pd
from google.colab import drive,files
drive.mount('/content/drive')
f1=pd.read_csv(r'/content/drive/My Drive/Colab Notebooks/first_sheet.csv', low_memory=False,encoding= 'unicode_escape')
f2=pd.read_csv(r'/content/drive/My Drive/Colab Notebooks/second_sheet.csv', low_memory=False,encoding= 'unicode_escape')
df = f1.merge(f2, on = "primary_key",how = "outer")
df.to_csv(r"Results.csv")
files.download('Results.csv') After pasting the code go to runtime in the menu and click run all. Now go to google drive inside Colab Notebooks folder you will find Results.csv there.
