Load File from Stream
Leave feedback
On this page
To avoid persisting intermediate files, work with file streams directly. Pass an open binary stream to Comparer and add().
- Open the source and target files as binary streams.
- Pass the source stream to the
Comparerconstructor. - Pass the target stream to
add(). - Call
compare()with the result path or output stream.
from groupdocs.comparison import Comparer
def load_file_from_stream():
with open("./source.docx", "rb") as source_stream, \
open("./target.docx", "rb") as target_stream:
with Comparer(source_stream) as comparer:
comparer.add(target_stream)
comparer.compare("./result.docx")
print("Documents compared successfully. Check output in result.docx.")
if __name__ == "__main__":
load_file_from_stream()
source.docx is the source file used in this example. Click here to download it.
target.docx is the target file used in this example. Click here to download it.
Binary file (DOCX, 25 KB)
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.