Search code examples
emeditor

Output Text between 2 lines using filtering option


We are using EMEditor for logfile analytics in huge textfiles. We have following requirement.
In the logfile, there are a lot of tables in this format:

+----------------------+
|Column1|Column2|Colum3|
+-------+-------+------+
|Data1  |Data2  |Data3 |
|Data4  |Data5  |Data6 |
+-------+-------+------+
| Number of Records: 2 |
+----------------------+

The text between the header and footer is very dynamic; it could be 0 or x-lines between it.

I would use the filter option in this way, that I input for example |Column1 using the start filter and | Number of Records: as end filter. EMEditor should filter all records between start- and end filter (inclusive line with the found filter patterns).

I have seen, it's currently only possible to output lines above and under the filter pattern, but this is no practicable way.

How can I achieve this?


Solution

  • If + and | characters are used only for tables, you can filter tables by these characters. To do this, you can click the Advanced Filter button in the Filter toolbar, click Add button and enter +, click Add button again to enter |, and set the Logical Disjunction (OR) to the Previous Condition option to the second item in the list. Finally, click Filter button.

    Updates

    Download EmEditor v20.0.902 or later, and use the Begin Filter and End Filter options in the Advanced Filter. Advanced Filter

    If you would like to use a macro, this is a macro for you:

    filters = document.filters;
    filters.Clear();
    filters.AddFind( "|Column1", eeFindReplaceCase, eeExFilterBegin );
    filters.AddFind( "| Number of Records:", eeFindReplaceCase, eeExFilterEnd );
    document.filters = filters;
    

    You can run this macro after you open your data file. To do this, save this code as, for instance, Filter.jsee, and then select this file from Select... in the Macros menu. Finally, open your data file, and select Run in the Macros menu while your data file is active.