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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login