I am running this script in Python to find a certain line in a file. askopenfilename
will ask what file I want to search and the f.write will save the results into a file. How do I automatically save this file in the same place I found the original file?
from tkFileDialog import askopenfilename
filename = askopenfilename()
file = open(filename, "r")
for line in file:
if "INF: Camera timeout" in line:
with open("../timeouts.txt", "a") as f:
f.write(line)
f.close
Also askopenfilename
opens behind the other windows, how do I make it open on top?