Search and mark between date and time



  • I have an massive 2 150 998 line long log file.
    Need to search and mark 2016-01-01 06:00:00 and 2016-01-01 23:59:59 for an example, so I can copy it to Spreadsheet

    Find many solutions of search and replace, but I just need to find the data and copy it.



  • Excuse for my not so good English and couldn’t update it so I post it one more time with, hopefully more clearly content.

    I have an massive 2 150 998 line long log file.
    Need to search and mark between (for an example) 2016-01-01 06:00:00 and 2016-01-01 23:59:59, so I can copy it to Spreadsheet

    Find many solutions of search and replace, but I just need to find the data and copy it.



  • @Sven-Ryglert

    You didn’t clarify anything between post #1 and post #2. :)

    I think more detail is needed…what has been specified about your data isn’t enough for someone to help well. YOU can see your data so it is clear in your mind, but for anyone wanting to help what you’ve said just leads to more questions when they think about implementing a solution.



  • @Sven-Ryglert I believe you want to find a string (example is 2016-10-01 06:00:00), start marking, find another string (example is 2016-01-01 23:59:59), stop marking so that all text from string1 to string2 is marked so it can be copied to another file.

    I would think that a regex search should be able to do this. Something like:

    ^.*2016-10-01 06:00:00(.*\R)+.*2016-01-01 23:59:59.*\R
    

    should mark the first line containing 2016-10-01 06:00:00 through the line containing 2016-01-01 23:59:59.



  • Sorry Scott that I was vague. The English language is a bit tricky for me. I think Jim understood me.

    But just to try to show what I mean. This is how our data looks like in short and the users are marked Xxxxx
    I want to search and mark 2016-10-01 23.59.18 to 2016-10-01 23.59.49 It is tedious to do it manually when the full file contains over 2 millions of lines.

    2016-10-01 23:59:18 PLAY Xxxxx
    2016-10-01 23:59:29 PLAY Xxxxx
    2016-10-01 23:59:39 PLAY Xxxxx
    2016-10-01 23:59:49 PLAY Xxxxx
    2016-10-02 00:00:09 PLAY Xxxxx
    2016-10-02 00:00:29 PLAY Xxxxx
    2016-10-02 00:00:39 PLAY Xxxxx

    I have been searching for this regex plugin and found an dll file that I have installed but can’t see how to bring that regex dialog window up…



  • @Sven-Ryglert

    I tried your example data, and inserted some dummy lines in between your “PLAY” lines because I’m guessing that is what your situation really looks like (to account for 2 million lines).

    I had some good luck with this search setup:

    Open the Find dialog; select the Find tab within it
    In the Find What box, put (?s)^(\d{4}-\d{2}-\d{2}).+\1(?-s).+
    Take care not to have any leading/trailing/embedded spaces in that!
    Select Regular Expression as the search mode
    Move the caret to the very top of your file
    Press the Find Next button
    The entire first day’s “PLAY” line matches should get selected and then can be Copy’d to the clipboard
    Press the Find Next button again
    The second day’s “PLAY” matches will get selected…
    This really isn’t much different from Jim’s solution, just a bit more generic.

    This can be extended to make even more refinements, but given the spec that was given… :)

    Not sure what you mean about a regex plugin, but what Jim and I have described requires no plugin.



  • Thanks Scott. The log shows material that is playing between 10 and 15 sec before next material is played and that goes on 24/7 therefore it generates a heavy load of lines…

    I just found out another solution

    I searched for 2016-10-02 from top of the doc and 2016-10-02 00:00:09 was marked
    Then I clicked on Edit and Mark start/end from the Notepad menu
    Made another search for 2016-10-02 but checked Loop and Up and 2016-10-02 00:00:39 was marked
    Edit and Mark start/end again. Hepp! The span was marked up and easy to copy.

    Thanks Jim and Scott. i have been learning a lot from your answers.



  • @Sven-Ryglert Thank you. I didn’t know there was a command on the Edit menu to Start/Stop marking text, even after about 5 years of using N++! :-)



  • Yes, the Edit -> Begin/End Select is a pretty handy thing when you need to select huge sections of text; sadly it does not have a default shortcut keycombo.

    It might be little-known that you can also do column-selections with it, for example, invoke Begin/End Select at a starting point, move to a different point by alt+Lclick, then invoke Begin/End Select again and you get a column block between the two points.



  • @Scott-Sumner Boom!! The sound of my head exploding! Yet another great new discovery.



  • @Jim-Dailey

    How about one more? You don’t have to use the mouse for the column-select: At a starting point, invoke Begin/End Select. Move the caret downward to a new point, then Shift+Alt+RightArrow to highlight a single character that you want as the last character in the column block. Invoke Begin/End again. Boom…column block. :)

    Also works similarly if the starting point is below the ending point…



  • Hello, Scott

    I haven’t noticed the relation between the Begin/End select feature and the column mode selection, yet ! Many thanks for these very nice tricks, indeed !

    Cheers,

    guy038


Log in to reply