I have two files, let's say File A and B. And I want to get a specific value after the word "Query" in File A and find that value in File B, which is a large file. After which if it matches, the python program will print "Sorry, item already exist".
One caveat is that File B is exported from a platform, so gibberish/additional data will be present.
An example of the files can be seen as shown below:
File A:
{"ID": "01", "Name": "..", "Query": "zzzzzzzzzzz"}{"ID": "02","Name": "..", "Query": "xxxaaaaxxxx"}
File B
[_some fileheader info]{"ID": "...", "Name": "..", "Query": "kkkkkkkkkk"}{"ID": "...", "Name": "..", "Query": "xxxxxxxxx" }{"ID": "...", "Name": "..", "Query": "zzzzzzzzzzz"}{"ID": "...", "Name": "..", "Query": "pppppppppp"}
So the expected outcome will be printed - "Entry ID 01 already exist in File B!"
This is what I am working on (am unsure how to specifically search for "Query"), but doesn't seem to work:
with open('FileA') as f1:
with open('FileB') as f2:
if f1.read() in f2.read():
print("Entry already exist!")
else:
print("Importing entry....")