f = open("Trades.txt","r")
writer = open("trading.txt","w")
options = input("A:Check trades for 1 or more players/B:Check trades between 2 players: ").lower()
if options == 'b':
player1 = input("Enter the name of player 1: ")
player2 = input("Enter the name of player 2: ")
for lines in f:
if player1 and player2 in lines:
writer.write(lines)
Text file looks something like this:
=======================
[time] player trading with playerx
(To: player, From: playerx)
item
=======================
[Jan 13, 2016 11:53:49 PM Central European Time] y trading with x
(To: x, From: y)
item
=======================
The user will be asked to enter 2 names to find in the text file.
These 2 names will have to be found in the text, which I have done.
Then, the lines AFTER the line with the names will have to written to a file UNTIL it reaches "=======================".
So the written data would look something like:
[time] player trading with playerx
(To: player, From: playerx)
item
Thanks in advance
P.S The number of lines after the names will vary so can't write like a set amount of lines after the match