Im sure this is a simple readlines solution. I have spent some time trying to solve it without success.
I have a block of text that reads:
"This is the text 1"
0.0 2.0 2.0 2.0
0.0 0.0 4.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
"This is the text 2"
0.0 5.0 3.0 5.0
0.0 0.0 6.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
and I am struggling to change it to:
"This is the text 1"
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 4.0 0.0
0.0 2.0 2.0 2.0
"This is the text 2"
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0
0.0 0.0 6.0 0.0
0.0 5.0 3.0 5.0
Any help greatly appreciated. Thanks
Code:
f = open("file.txt", "rb")
s = f.readlines()
f.close()
f = open("newtext.txt", "wb")
f.writelines(s[::-1])
f.close()
Returns the whole txt file inverted.