Text file manipulation

Text file manipulation

2
NewbieNewbie
2

    Jun 21, 2006#1

    Hi, I just purchased UE, (love it) but am still stuggling with macros I checked the forum for something close but didn't find it. What I have is a log files that are exactly the same number of bytes 4018KB, most of the file contains usless data, so I need a macro to say remove line 36-119, 159-457,678-7000, 7300-12000. My logger generates 120 files a day so I need to apply this to all files as it opens

    Is there a easy was to do this.

    206
    MasterMaster
    206

      Jun 21, 2006#2

      Maybe something like this. You could set it to run automatically whenever UE opens.

      GotoLine 7300
      GotoLineSelect 12000
      Key BACKSPACE
      DeleteLine
      GotoLine 678
      GotoLineSelect 7000
      Key BACKSPACE
      DeleteLine
      GotoLine 159
      GotoLineSelect 457
      Key BACKSPACE
      DeleteLine
      GotoLine 36
      GotoLineSelect 119
      Key BACKSPACE
      DeleteLine
      Software For Metalworking
      http://closetolerancesoftware.com

      2
      NewbieNewbie
      2

        Jun 22, 2006#3

        Thank you very much for your prompot reponse.

        That worked great!
        I do have one more question, Sorry still trying to learn the macro language

        I want to search though a range of lines 74-128 and if the character at column 30 = 0 then delete the line,
        then move on to the next group at

        267-1280 and then the same thing if col 30 = 0 delete line.

        and so on

        thanks again in advance,

        Mike :idea: :?:

        6,686585
        Grand MasterGrand Master
        6,686585

          Jun 23, 2006#4

          The problem here is that a line cannot be deleted immediately if the character at column 30 is 0 because this will change the number of lines also immediately. So first all lines to be deleted must be marked and then the lines can be deleted all at once with a Replace All command.

          This should work with macro property Continue if a Find with Replace not found enabled:

          InsertMode
          ColumnModeOff
          HexOff
          UnixReOff
          GotoLine 74
          GotoLineSelect 128
          Find RegExp "%^(?????????????????????????????0^)"
          Replace All SelectText "DELTHISLINE>>>^1"
          EndSelect
          GotoLine 267
          GotoLineSelect 1280
          Find RegExp "%^(?????????????????????????????0^)"
          Replace All SelectText "DELTHISLINE>>>^1"
          EndSelect

          and so on

          Top
          Loop
          Find MatchCase RegExp "DELTHISLINE>>>*^p"
          Replace All ""
          IfNotFound
          ExitLoop
          EndIF
          EndLoop


          I use a loop over the final replace all because some older versions of UE have had problems to delete whole lines matching the search expression when the search string (line) matches consecutive lines. With latest version of UE the replace all command should be executed only once.

          Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style. Or translate the regular expressions to Unix/Perl syntax and use UnixReOn or PerlReOn at top of the macro.

          Note: The final replace all regular expression is written for a file with DOS line terminations or an Unix/Mac file which is loaded with conversion to DOS temporarily or permanently.
          Best regards from an UC/UE/UES for Windows user from Austria