0

I have gotten 2 http pages and I want to compare between them at Python. The problem is I got the files in different ways: In the first page the content is divided to blocks and in the second the content is in one block.

is there an elegant way to compare between them?

1 Answer 1

1

Hi this solution read two files, after exclude blank lines, and finally prints common lines regardless of their position in the file

with open('your_file_1', 'r') as file_1:
    with open('your_file_2', 'r') as file_2:
        same = set(file_1).intersection(file_2)

same.discard('\n') # exclude blank lines

with open('output_file.txt', 'w') as file_out:
    for line in same:
        file_out.write(line)
Sign up to request clarification or add additional context in comments.

2 Comments

I didn't mention that, but before every block there is number meaning the size of the block. Additionally, I don't understant it very much but דs it possible that the one block isn't appending of the blocks in the second page?
how can I send you them? I wanted to upload a screenpicture but I can't upload pictures until I would do something..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.