Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Creating a Join Line Macro to work on row groupings

2. Help
2014-02-25
2014-03-01
  • gina kavesh
    gina kavesh
    2014-02-25

    I have a large error file that reports 3 lines per 'error' listing that I am trying to merge all 3 lines into 1 line.
    When I highlight the 3 lines in Notepad++ then do join line (ctl-j) works great BUT working through 12000 lines manually doesn't seem effective.
    I create a Macro by recording my steps & it works BUT I still need to highlight the rows & then run the macro.
    Is there a way to create a macro that highlights the rows as the first step of the macro then run the line join command? Seems like there should be but I'm not seeing how to record/create that step.
    Any help is appreciated.

     
  • THEVENOT Guy
    THEVENOT Guy
    2014-02-28

    Hello Gina,

    I think that your problem can be solved by the use of regular expressions :-)

    But, of course, I need a few examples of these error blocks, in order to find out the under-structure of these 3 lines.

    When this first step done, it shouldn't be very difficult to join each block of 3 lines into a single line !

    Best Regards,

    guy038

     
    Last edit: THEVENOT Guy 2014-02-28
  • GerdB
    GerdB
    2014-03-01

    How about this:

    1. Open your file
    2. Make sure caret is at beginning by hitting Ctrl-Home
    3. Start Macro recording
    4. Hit the following Keys: Shift-Down, Shift-Down, Ctrl-j, Down
    5. Stop Macro recording
    6. Activate "Run a Macro multiple times" and choose "Run until the end of file"

    hope this helps

    Regards
    Gerd

     
  • THEVENOT Guy
    THEVENOT Guy
    2014-03-01

    Hi Gina, GerdB and All,

    The GerdB's solution is nice too, because you can affect a shortcut to this macro.

    But, if your log file contains ONLY a list of errors, with 3 lines per error, without any other text, you can use the general regex below :

    SEARCH : (.+)\R(.+)\R(.+)

    REPLACE : \1 \2 \3 with a space after digits 1 and 2

    • Place the cursor at the beginning of the first group of 3 lines.

    • Fill in the two zones, Find what and Replace with, with the two regexes above.

    • Click on the Regular expression radio button.

    • Uncheck, if necessary, the . matches newline square button.

    • Click on the Replace All button.

    Et voila !

    Guy038

    P.S. :

    In the general case where the text, to group in n lines, may contain empty lines, use the S/R below :

    SEARCH : (.*)\R(.*)\R(.*)\R......(.*)\R

    REPLACE : \1 \2 \3 .......\n\r\n

    As I added \R at the end of this SEARCH regex, the last part will match, at least, the EOL character(s) of the last line of each n-lines set

     
    Last edit: THEVENOT Guy 2014-03-01