Compare Excel Sheet Using Python Programming Language: HelpWithAssignment.com

Using python programming language, compare the below excel sheets and print out what's the same and different in both sheets.

excel file 1:

Name Path  
python-excel users/python/excel
python-excel1 users/python/excel1
python-excel2 users/python/excel2
python-excel3 users/python/excel3
python-excel4

users/python/excel4

excel file2:

Name Path
python-excel users/python/excel
python-excel1 users/python/excel1
python-excel9 users/python/excel9
python-excel3 users/python/excel3
python-excel4 users/python/excel4

 

Solution: 

def print_difference_of_excel_files(File1,File2):

#read full excel1 file
file1=open(File1,'r')
excel1_content=set(file1.readlines())
file1.close()
# print(excel1_content)

#read full excel2 file
file2=open(File2,'r')
excel2_content=set(file2.readlines())
file2.close()
#print(excel2_content)

  
  
#print difference of two sets for differences
print('nn differences nn')
for line in excel1_content-excel2_content:
print(line)
for line in excel2_content-excel1_content:
print(line)
  
#print intersection of two sets for same things

print('nn same things nn')


for line in set(excel1_content).intersection(excel2_content):
print(line)

print_difference_of_excel_files("excel1.xlsx","excel2.xlsx")

PythonAlIOne.py X Solution Explorer print-difference-of-excel-files 团CAWIN exe Edef print-difference-of-excel-files(File1,File2): file1-open (Filel,r) excell content-set(file1.readlines ()) file1.close) (Ctrl+:) e (1 pro differences # print (excell-content) python-excel2, users/python/excel2 file2-open (File2,r) excel2_content-set(file2.readlines)) file2.close() #print (exce12-content) python-exce19,users/python/excel9 .txt .py r.py same things print(Inln differences Inn) for line in excell content-excel2 content: h_ i.py r.py python-exce13,users/python/exce13 python-excel1,users/python/excel1 python-excel4, users/python/excel4 print(line) for line in excel2 content-excell content: Explorer print (line) lame, Path python-excel,users/python/excel ress any key to continue . . . print( nin same things Inin) for line in set (excell_content).intersection(excel2_content): print(line) print difference of excel files(excel1.xlsx, excel2.xlsx) 100 % Activate Windo Go to Settings to ac Error List Output

Download

Comments

  • HWA
    Rasha

    this is a very good website

  • HWA
    maani

    I have 50 questions for the same test your page is showing only 28

  • HWA
    joeanne

    hi can you please help or guide me to answer my assignments. thanks

  • HWA
    joeanne

    hi can anyone help or guide me to my assignments. thanks

  • HWA
    Monik


  • HWA
    Cristina

    This solution is perfect ...thanks

  • HWA
    Janete

    Hello Allison,I love the 2nd image that you did! I also, had never heard of SumoPaint, is something that I will have to exolpre a bit! I understand completely the 52 (or so) youtube videos that you probably watched. Sometimes they have what you want, sometimes they don't! However, it is always satisfying when you are able to produce something that you have taught yourself. Great job!Debra 0 likes

  • HWA
    Sandeep

    Perfect bank of solution. 

  • HWA
    Oxana

    great !

  • HWA
    Paul Brandon-Fritzius

    thanks for the quick response. the solution looks good. :)

  • HWA
    tina Johnson

    thnx for the answer. it was perfect. just the way i wanted it. 

  • HWA
    Giuseppe

    works fine.