Compare Two Excel Sheets with Different Number of Rows and Find Differences using Python

  Рет қаралды 61,699

Coding Is Fun

Coding Is Fun

Күн бұрын

Пікірлер: 114
@xilllllix
@xilllllix 2 жыл бұрын
this has plenty of day-to-day uses, thanks!
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Great to hear & thanks for watching the video!
@ankitait2
@ankitait2 4 ай бұрын
exactly what I was looking for. good job and thank you
@CodingIsFun
@CodingIsFun 4 ай бұрын
Glad I could help! Cheers, Sven ✌️
@ghoshasish99
@ghoshasish99 2 жыл бұрын
Fabulous video! Excellent explanation and perfect solutioning..
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thank you very much. Happy to hear that you liked the video!
@DeepakKumar-cx5tr
@DeepakKumar-cx5tr Жыл бұрын
Thank you, i was looking for something like this
@CodingIsFun
@CodingIsFun Жыл бұрын
Happy to hear that it was useful. Thanks for watching! 👍
@freak2fun801
@freak2fun801 Жыл бұрын
Hey awesome video. You have put a lot of effort here. Thanks for that. Just a query how to compare 2 Excel with some common and some different columns details
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
@bc4198
@bc4198 2 жыл бұрын
Thank you! I run into this type of task pretty regularly. Excel doesn't have a built-in formula / tool for this, right? It would take a bunch of LOOKUPs and stuff?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
You could also replicate it with Excel formulas, but adding (automatically) comments to cells would only be possible using VBA.
@albertomontero9809
@albertomontero9809 2 жыл бұрын
Thanks!
@CodingIsFun
@CodingIsFun 2 жыл бұрын
And I thank YOU, Alberto Montero. It appreciate your support. 🙏
@VoltaireParis
@VoltaireParis Жыл бұрын
awsome in all ways : big thanks and big kudos for your clear & clever explanations !
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks for the positive feedback! Appreciate you taking the time to leave a comment.
@tseringdolmagangsudora8292
@tseringdolmagangsudora8292 8 ай бұрын
thanks for the video. If you could also make a video on how to compare two JSON files with different actions and find differences using Python. Thank you
@CodingIsFun
@CodingIsFun 8 ай бұрын
Thanks for watching and your video suggestion! Cheers, Sven 👍
@SanS-oo9hy
@SanS-oo9hy Жыл бұрын
Great content. Thanks for the code. !!
@CodingIsFun
@CodingIsFun Жыл бұрын
You're very welcome! Thank you for watching and for the comment!
@KhalilYasser
@KhalilYasser 2 жыл бұрын
Thank you very much for these incredible tutorials.
@CodingIsFun
@CodingIsFun 2 жыл бұрын
An absolute pleasure, Yasser Khalil! Thanks for the kind comments! 👍
@jeyapauldavid5596
@jeyapauldavid5596 4 ай бұрын
Thank you so much very useful to me.
@CodingIsFun
@CodingIsFun 4 ай бұрын
Happy to hear that it was useful; thank you for taking the time to leave a comment and for watching the video! Cheers, Sven ✌️
@alexk7837
@alexk7837 10 ай бұрын
Hello, what is your take on comparing XLSXs that have cells with multiline string values (ie, 7 lines of text). Pandas seems to be strangling with those.
@CodingIsFun
@CodingIsFun 10 ай бұрын
Thanks for watching. I haven't tried that, but I guess the xlwings method shown in the video should work . Happy coding!
@yogeetjain7077
@yogeetjain7077 Жыл бұрын
Hey , this is a great video ,my task was majorly done ,but xlwings does not run when we use the highlight code for very large datasets. Moreover if you could provide a video where we can compare files having different number of columns it would be very helpful.
@CodingIsFun
@CodingIsFun Жыл бұрын
Thank you for watching the video & your suggestion.
@vilaspatil4387
@vilaspatil4387 8 ай бұрын
I have source sheet 60000 rows and target sheet having 32000 i want to find which rows are missing based on three column like item_code, start-date and cost. How to do this??
@CodingIsFun
@CodingIsFun 8 ай бұрын
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
@anila556
@anila556 Жыл бұрын
It's a great video, When I test this in my mac, it is throwing me permission issue in the line "initial_wb = app.books.open(initial_version)". Googled various websites couldn't find any helpful information.
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks for watching and for your question. Hard to tell from a distance why you are facing an error. Sorry that I cannot help.
@sureshakkavarapu9986
@sureshakkavarapu9986 7 ай бұрын
thanks for the video & explanation , if possible can you pls share the gitrepo or sample utility to test locally ???
@CodingIsFun
@CodingIsFun 7 ай бұрын
Thank you for watching. You can always find the relevant links from my videos in the video description. Here you go: github.com/Sven-Bo/compare-two-excel-sheets-python. Happy coding and testing! Cheers, Sven ✌️
@eninadia1309
@eninadia1309 6 ай бұрын
how can i do this comparison if my excel files have different column names and different rows?
@CodingIsFun
@CodingIsFun 6 ай бұрын
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
@CODUlTiMaTeBaWsS
@CODUlTiMaTeBaWsS 2 жыл бұрын
Hi! Thank you for this great video! It has helped me out a lot! I just had one question though, I used the code from the second part of the video however when i execute my code, the rows on my worksheet don't get colors.
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching and for your question. Hard to tell from a distance why the cells do not get a color. Sorry that I cannot help.
@sagarkadam2445
@sagarkadam2445 2 жыл бұрын
if there is only column difference can you highlight with different color and if the entire row is not present in any of the file can you highlight with different color? This will give you an idea if there is only one column that is different or the entire row is not present in any of the file
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Highlighting the entire row that was not in the initial file has been covered in the video (09:28 min). You could take that example as a starting point to check further (column by column) if the change is only in one column to use a different colour. I hope you understand that I am missing the time to code out an example for you. Happy Coding!
@曹元成
@曹元成 2 жыл бұрын
If I have a template workbook with 20+ shape-protected sheets, can I still use your code to find the diff between two ver? Or, what else should I do?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching. Not sure. You might just want to give it a try to find out.
@mohithasharma5000
@mohithasharma5000 2 жыл бұрын
After getting the data, which exists in right_only sheet, (8:41) I am getting all the index as NaN and I am not able to convert that to python list. It still remains NaN. How can I proceed?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Hard to tell from a distance. Not sure what might be causing the issue.
@sowmyavikendi
@sowmyavikendi Жыл бұрын
Can we do comparison if had more than one worksheet?
@CodingIsFun
@CodingIsFun Жыл бұрын
That should be possible, but I have not tired it yet.
@AllinOne-xt1wv
@AllinOne-xt1wv Жыл бұрын
Hi, I have a doubt, if our initial version file has 100 rows and updated version has two to three-rows deleted in between of that file. when try to follow your code, it skip that deleted details. Difference highlighted csv not showing this deleted details. pls help. I am new to this
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks for watching. I am not sure to which method you are referring to. In the video, showed different methods and also the use cases (and limitations) for each of those methods.
@clairelee9056
@clairelee9056 3 ай бұрын
@@CodingIsFun I think he means what if the updated version of the excel file has missing rows. Is it possible to add these missing rows into the updated excel in a different font colour?
@CodingIsFun
@CodingIsFun 3 ай бұрын
@@clairelee9056 That sounds possible but of course, would require some additional coding.
@mikeniemotka9547
@mikeniemotka9547 Жыл бұрын
Hello. GREAT video, and I think this is just the code I am looking for, but I am just starting to learn Python, and how to use GitHub. when I went to the link for this code, I could not figure out how to get just the Python code. Is there a way to extract it from from the Compare_Workbooks.ipynb file that is contained in the ZIP file?
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks for watching. Here a couply of ways to convert the Notebook to a Python file: mljar.com/blog/convert-jupyter-notebook-python/ I hope it helps! Happy Coding!
@mikeniemotka9547
@mikeniemotka9547 Жыл бұрын
@@CodingIsFun I am using jetbrain, not sure if that is the same as a jupyter? I tried to import the ipynb file that I I downloaded from you, but don't see any of those commands in the link you showed me. And other help would be greatly appreciated. Also, did you ever write a version where you had the a final file that would show the original AND the revised content of any changed cells?
@pavanr1271
@pavanr1271 Жыл бұрын
Hii, Can we change the self and other to any other names?
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks for watching. Yes, you can using the result_names parameter as written in the pandas docs: pandas.pydata.org/docs/reference/api/pandas.DataFrame.compare.html
@howard_roark1210
@howard_roark1210 2 жыл бұрын
hey thanks for the tutorial. I am unable to import path from pathlib. this throws me an error, 'ImportError: cannot import name 'path' from 'pathlib' ! can you please help me
@CodingIsFun
@CodingIsFun 2 жыл бұрын
capitalize Path from pathlib import Path
@howard_roark1210
@howard_roark1210 2 жыл бұрын
@@CodingIsFun that worked!! thank you . You earned a subscriber!!
@howard_roark1210
@howard_roark1210 2 жыл бұрын
can you help me with the code that actually compares two excel files and copies the data only between corresponding cells which has a common name in the first column.
@CodingIsFun
@CodingIsFun 2 жыл бұрын
@@howard_roark1210 What have you tried so far?
@kingofthesummer5180
@kingofthesummer5180 2 жыл бұрын
Hi, I have a question… in the data with different shapes sections, what if the difference in the shape of the excel file was that additional columns were added or both columns and rows changed, how would you handle that?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
It's a good question but difficult to answer because it depends on many factors. Before comparing the data, you would probably need to check the shape of the data range and/or the column header (names). That said, I do not have the time to code an example.
@serageibraheem2386
@serageibraheem2386 2 жыл бұрын
Great video, thank you.. I have a question please, if Excel starts at 0 and pandas starts at 2, should not we add 3 no 2? please advise
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching. I recommend downloading the Jupyter Notebook and 'playing' around with the figures. Happy Coding!
@serageibraheem2386
@serageibraheem2386 2 жыл бұрын
@@CodingIsFun I got it as I was practicing... do you think that we can highlight values only not yhe whole row as you did in the first part of the video?
@serageibraheem2386
@serageibraheem2386 2 жыл бұрын
@@CodingIsFun I got it as I was practicing... do you think that we can highlight values only not yhe whole row as you did in the first part of the video?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
@@serageibraheem2386 It might be possible, but I do not know how to implement that right off the bat.
@serageibraheem2386
@serageibraheem2386 2 жыл бұрын
@@CodingIsFun I will try and let u know.... thank uuuu so much 👏👏
@sunilkumar-gs3ex
@sunilkumar-gs3ex Жыл бұрын
How to compare a specific number of rows of the excel sheets instead of all the rows?
@CodingIsFun
@CodingIsFun Жыл бұрын
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
@sunilkumar-gs3ex
@sunilkumar-gs3ex Жыл бұрын
@@CodingIsFun Okay! Thanks for the reply!
@sahraouikhaoula3487
@sahraouikhaoula3487 2 жыл бұрын
in my code, i want to compare two elements if they are in the same column, how could i achieve that? thank you
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
@monalisa-gp6nk
@monalisa-gp6nk 2 ай бұрын
Please make a video by using pandas.
@CodingIsFun
@CodingIsFun 2 ай бұрын
I also used pandas in the video.
@akshaybhat9040
@akshaybhat9040 2 жыл бұрын
for each row in source1.csv ,find all matching values from source2,csv how its done please help me to solve this. thank you
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching and for your question. By merging the dataframes - similar to what I have demonstrated at 7:04 min. Happy Coding! :)
@Vinodglobaldata
@Vinodglobaldata Жыл бұрын
At 4:18. What if i want Last Name as Index no instead of [10,21,56,85,99]. i have used this code so many times but i want the above solution to make my work easy. Kindly revert back with help. Thank You.
@CodingIsFun
@CodingIsFun Жыл бұрын
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
@priyanshijain2693
@priyanshijain2693 3 ай бұрын
Where we can find the code for this ?
@CodingIsFun
@CodingIsFun 3 ай бұрын
Thanks for watching. Link is in the description. Here you are: github.com/Sven-Bo/compare-two-excel-sheets-python Cheers, Sven ✌️
@milkway731
@milkway731 2 жыл бұрын
What if these 2 excels are different shpe? one is 32 row, another is 33 row? And I want to find what the differences ..
@CodingIsFun
@CodingIsFun 2 жыл бұрын
06:32 min
@tpalexander1549
@tpalexander1549 2 жыл бұрын
Hai Can you help to find the difference in two excel sheet having multiple tabs also that tab having differences in the rows and columns.?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching the video. Unfortunately, I do not have the time to code out an example tailored to your specific use case. I hope you can understand. Thank you!
@tpalexander1549
@tpalexander1549 2 жыл бұрын
@@CodingIsFun I know you very busy. But you can do as a video it self ☺️ it will help me like people's i hope you understand the issue.thank you
@npc118
@npc118 2 жыл бұрын
I’m not very good at all in except. If I’m working on two spreadsheets one being the one that is uploaded with changes found in the second spreadsheet. If I use one these functions to compare do the column names have to be identical in both excel files or can they be similar. Sorry I’m so new to this and I just want to cry 😢
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching. When using pandas, the column headers need to be identical. However, you could also rename the column headers before using the compare method. Here is how you do it: stackoverflow.com/a/11354850 I hope it helps! Happy learning & coding! :)
@premshilu
@premshilu 2 жыл бұрын
its showing that Book object does not have used_range attribute pls help
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Probably because you are using 'used_range' on a workbook and not on a worksheet object.
@sat1460
@sat1460 2 жыл бұрын
this can help bank reconcilation in excel
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Glad you think so! Thanks for watching & your comment! :)
@calm_compost
@calm_compost 2 жыл бұрын
I wonder if the logic work if say the datasets have no unique identifiers ?
@CodingIsFun
@CodingIsFun 2 жыл бұрын
Thanks for watching. What exactly do you mean by unique identifiers? In the xlwnigs example, the header names do not matter. The script will compare cell to cell, e.g. A1 (WB1) to A1 (WB2). When using pandas compare, you want to use the same column headers.
@calm_compost
@calm_compost 2 жыл бұрын
@@CodingIsFun By unique identifier i meant to say that one field that distinguishes my row from the rest of the rows and which stays same throughout any point of time. Anyway I will try to replicate this logic in Excel and see if it helps. Thanks for the video though.... :)
@saurabhsharma-bd1xf
@saurabhsharma-bd1xf 2 жыл бұрын
Hey I am facing issue with updated_wb.save() thing. Its giving me lot of errors
@CodingIsFun
@CodingIsFun 2 жыл бұрын
What does the error say?
@saurabhsharma-bd1xf
@saurabhsharma-bd1xf 2 жыл бұрын
@@CodingIsFun Traceback(most recent call last): file "",line 1 in Files "C\users\sharma\appdata\local\program\python\python310\lib\site-packages\xlwings\main.py", line 903 , in save with self.app.properties(display_alerts_false): Files "C\users\sharma\appdata\local\program\python\python310\lib\site-packages\xlwings\main.py", line 867 , in app return(app(impl=self.impl.app) Files "C\users\sharma\appdata\local\program\python\python310\lib\site-packages\xlwings\_xlwindows.py", line 551 , in app return App(xl=self.xl.application) Files "C\users\sharma\appdata\local\program\python\python310\lib\site-packages\xlwings\_xlwindows.py", line 135 , in __getattr__ v= getattr(self._inner, item) Files "C\users\sharma\appdata\local\program\python\python310\lib\site-packages\wincom\client\__init.py__", line 645 , in __getattr__ return getattr(d, attr) Files "C\users\sharma\appdata\local\program\python\python310\lib\site-packages\wincom\client\__init.py__", line 548, in __getattr__ return self.ApplyTypes(*agrs) Files "C\users\sharma\appdata\local\program\python\python310\lib\site-packages\wincom\client\__init.py__", line 572, in _ApplyTypes_ self.oleobj_InvokeTypes(dispid, 0, wflags, retType, argTypes, *args), pywintypes.com_errror:(-2147023170, 'The remote procedure call failed.', None, None)
@saurabhsharma-bd1xf
@saurabhsharma-bd1xf 2 жыл бұрын
I really apprecaite if you can help me in resolving the error. I used the word to word code of yours and everything is working perfectly fine but i don't know why its giving error on save function. i tried several ways but nothing worked out for me. I hope if you can trace the error in it. Thanks for your help.
@CodingIsFun
@CodingIsFun 2 жыл бұрын
@@saurabhsharma-bd1xf Please paste the error trace log here: pastebin.com/ Once done, share your paste bin ID (NOT THE FULL URL [links will be deleted by YT]), an example of pastebin ID: *MsEChyJw* ( www.screencast.com/t/7Q8W3zE8Rc )
@saurabhsharma-bd1xf
@saurabhsharma-bd1xf 2 жыл бұрын
@@CodingIsFun aaJDTjyV
@amitkhandelwal6866
@amitkhandelwal6866 Жыл бұрын
why you used hoe="outer" ? why not "inner"
@CodingIsFun
@CodingIsFun Жыл бұрын
Because I am looking for any additions or deletions between the two datasets (df_initial and df_update)
@amitkhandelwal8030
@amitkhandelwal8030 Жыл бұрын
@@CodingIsFun Ohk , but Inner join also gives the difference between two csv tables , so my doubt is how to identify if many rows deleted and added in df_update how to extract that particular rows
@CodingIsFun
@CodingIsFun Жыл бұрын
@@amitkhandelwal8030 why not simply trying it out. Feel free to share your solution here
@kevindandrade5307
@kevindandrade5307 2 жыл бұрын
Nope. didnt get the merged excel for different lengths excels --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in ----> 1 with xw.App(visible=False) as app: 2 updated_wb = app.books.open(prod_version) 3 updated_ws = updated_wb.sheets(1) 4 rng = updated_ws.used_range 5 AttributeError: __enter__
@kevindandrade5307
@kevindandrade5307 2 жыл бұрын
ok my bad. needed to update xlwings==0.25.3
@travelwithprinceandekta7364
@travelwithprinceandekta7364 2 жыл бұрын
@@kevindandrade5307 is there another way to fix this error with xlwings version 0.16.0 ?
@FabioMarcosBr
@FabioMarcosBr Жыл бұрын
👏👏👏👏🤌🤌🤌👍👍👍😊😊😊 Muito bom! Parabéns!
@CodingIsFun
@CodingIsFun Жыл бұрын
Glad you liked it. Thanks for watching and taking the time to leave a comment! 👍👍
Introducing Python in Excel
19:01
Leila Gharani
Рет қаралды 1,6 МЛН
Automate Excel With Python - Python Excel Tutorial (OpenPyXL)
38:02
Tech With Tim
Рет қаралды 1,6 МЛН
НИКИТА ПОДСТАВИЛ ДЖОНИ 😡
01:00
HOOOTDOGS
Рет қаралды 3 МЛН
Sigma baby, you've conquered soap! 😲😮‍💨 LeoNata family #shorts
00:37
Wait for the last one 🤣🤣 #shorts #minecraft
00:28
Cosmo Guy
Рет қаралды 15 МЛН
How To Compare Excel Files and Find Differences
10:47
Kenji Explains
Рет қаралды 73 М.
Python in Excel vs. VBA - What You Should Learn in 2024!
10:05
David Langer
Рет қаралды 54 М.
Comparing Value Difference Between 2 CSV Files using pandas
6:13
How to Compare Two Excel Sheets (and find the differences)
14:59
TrumpExcel
Рет қаралды 808 М.
Compare excel files using Python with Pandas
11:23
Stalin Jayapal
Рет қаралды 50 М.
Python in Excel Makes Power Query a MUST-HAVE in 2024!
13:19
David Langer
Рет қаралды 43 М.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Rob Mulla
Рет қаралды 273 М.
НИКИТА ПОДСТАВИЛ ДЖОНИ 😡
01:00
HOOOTDOGS
Рет қаралды 3 МЛН