Learn how to compare two Word documents using Python: https://blog.aspose.com/2021/11/11/compare-two-word-documents-in-python/
Last active
December 13, 2023 11:49
-
-
Save aspose-com-gists/e86343227ed63b2f0739c02b6a8c2f74 to your computer and use it in GitHub Desktop.
Compare Two Word Documents using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aspose.words as aw | |
from datetime import date | |
# load first document | |
doc = aw.Document("calibre.docx") | |
# load second document | |
doc2 = aw.Document("calibre2.docx") | |
# set additional options | |
options = aw.comparing.CompareOptions() | |
options.ignore_formatting = True | |
options.ignore_headers_and_footers = True | |
options.ignore_case_changes = True | |
options.ignore_tables = True | |
options.ignore_fields = True | |
options.ignore_comments = True | |
options.ignore_textboxes = True | |
options.ignore_footnotes = True | |
# compare documents | |
doc.compare(doc2, "user", date.today(), options) | |
# save the document to get the revisions | |
if (doc.revisions.count > 0): | |
doc.save("compared.docx") | |
else: | |
print("Documents are equal") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aspose.words as aw | |
from datetime import date | |
# load first document | |
doc = aw.Document("calibre.docx") | |
# load second document | |
doc2 = aw.Document("calibre2.docx") | |
# compare documents | |
doc.compare(doc2, "user", date.today()) | |
# save the document to get the revisions | |
if (doc.revisions.count > 0): | |
doc.save("compared.docx") | |
else: | |
print("Documents are equal") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Keep getting an error that the date is not defined. i added "import time" but still doesn't work