Python script rereplace stops working
-
Have written a small python script that would do a regular expression replace on each line changing a Epoch timestamp to a nicely formatted date/time. This operation is intended for our log files, so these files can get up to 20MB in size. What I find is that from time to time on larger files the rereplace stops working and shows a number of “CRLF” markings in the file.
Here is the script:
import time
def epoch_replace(m):
return time.strftime(“%Y-%m-%d %H:%M:%S”, time.localtime(int(m.group(1)) + 978307200))editor.beginUndoAction()
editor.rereplace(r"^([0-9]{9})", epoch_replace)
editor.endUndoAction()Any idea on why this might be happening? I re-wrote it to apply the rereplace on “chunks” of the file, but it appeared to make no difference. Also no difference if I avoided the undo action. However, if you do the undo occasionally it crashes Notepad++.
Any ideas?
-
Make sure you have periodic back ups turned off in the settings.