Python script to compare and merge excel files

Here I’m talking about a cool Python module using that you can compare two sheets in an excel sheet for a common value and merge the sheets.

First you need to install the module “pandas” for the solution. Python script is as below :

import pandas as pd

source1_df = pd.read_excel('a.xlsx', sheetname='Sheet1')
 source2_df = pd.read_excel('a.xlsx', sheetname='Sheet2')
 joined_df = pd.merge(source1_df,source2_df,on='Serial',how='outer')
 joined_df.to_excel('result.xlsx')

Note : replace the sheet1 and sheet2 with actual name of the pages and use the correct primary key name(Here “Serial”; case sensitive)

Eg :
sheet1 as below

Serial Hostname
123 abc
234 bcd
345 cde

 

sheet2 as below

Serial Model
234 Sparc
345 IBM
567 HP

 

After executing the python script, output comes  as below :

Serial Hostname Model
0 123 abc
1 234 bcd Sparc
2 345 cde IBM
3 567 HP

 

ENjoy 🙂

Keyboard copy paste shortcuts in putty commandline

Everyone know how to copy and paste characters in putty terminal using mouse (in case you don’t know, selecting the characters using mouse automatically copies and right click paste it) but less people know that it is possible with keyboard as well. You can use the below command to paste the characters into putty terminal

SHIFT + INS 

Enjoy 🙂