I have a .txt file and I want to search for a particular number in that file and get the following couple of characters. The number I want to find in the txt file comes from another txt file called "htmlBetId.txt". I am struggling to make the following code work:
RawFile = open("htmlraw2.txt","rt")
searchfile = RawFile.readline()
betFile = open("htmlBetId.txt","rt")
betID = betFile.readline()
betIDTest =str("'"+'"betId":'+betID[:8]+"'")
print(betIDTest)
left,sep,right = searchfile.partition(betIDTest)
print(sep)
When I run the code I get something like this (because of the print):
'"betId":88986745'
In this form, it can't find it.
Now if I write this in the previous code:
left,sep,right = searchfile.partition('"betId":88986745')
It can find it. The problem is that the number after "betId": changes so I have to make the first code work.
If you want the code and the txt files I can post them if you want. Thanks for your help!