How to find and delete rows that have length 50 resulting in having only rows with length not equal 50?

How to find and delete rows that have length 50 resulting in having only rows with length not equal 50?

1
NewbieNewbie
1

    Aug 25, 2017#1

    I work with large files that have a fixed length for each row of 50 characters. I commonly have files come to me where most of the file is good with the rows at lengths of 50 and a few rows either under or over 50. I would like to find and delete all the rows equal to 50 which would leave all the bad rows not equal to 50. Is there a way to do this?

    I think if I could find and remove all rows with a line feed in row 51 that would work too.

    I'm using version 21.10.0.1032

    11327
    MasterMaster
    11327

      Aug 25, 2017#2

      Search->Replace

      Find what: ^.{50}\R
      Replace with: leave empty
      Check Regular expressions and choose Perl
      Check Replace all from top of file
      It's impossible to lead us astray for we don't care even to choose the way.

      6,602548
      Grand MasterGrand Master
      6,602548

        Aug 25, 2017#3

        rmoran12 please note that last line in file must also have a line termination for this regular expression replace. Otherwise the string at end of file always remains in file even with having exactly 50 characters.

        By the way: It would be also possible to just search for lines with less or more than 50 characters to fix them manually, e.g. concatenate the too short lines because of line termination within a value which is most likely the reason for the too short lines.

        UltraEdit supports also just hiding all lines with exactly 50 characters and displaying only the lines with less or more than 50 characters for manual correction and then you can unhide all hidden lines with exactly 50 characters and continue processing the file.
        Best regards from an UC/UE/UES for Windows user from Austria

        11327
        MasterMaster
        11327

          Aug 25, 2017#4

          Mofi wrote:UltraEdit supports also just hiding all lines with exactly 50 characters ....
          Would you like to explain how to please?
          It's impossible to lead us astray for we don't care even to choose the way.

          6,602548
          Grand MasterGrand Master
          6,602548

            Aug 25, 2017#5

            How to hide all lines with exactly 50 characters?

            Let me explain that on a simple sample file with following content:

            Code: Select all

            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            0123456789012345678901234567890234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789x
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            01234567890123456789012345678901234567890123456789
            Open the regular Find dialog and enter as search string ^.{50}$, check the option Regular expressions and select Perl.

            Current file must be selected for option In. The check box options Match whole word, Match case Highlight all items found, List lines containing string and In column are all not checked.

            But checked must be the option Filter lines and selected next must be Hide.

            On running the find with clicking on button Next all lines are hidden containing a matching string. In this case with this Perl regular expression string it means all lines are hidden having exactly 50 characters.

            So the resulting display is:

            --- Lines are hidden ---
            0123456789012345678901234567890234567890123456789
            01234567890123456789012345678901234567890123456789x

            And there is the symbol [+] left to each of those 3 lines indicating that multiple lines are folded to a single line.

            The line number displayed in status bar or on left side if display of line numbers is enabled indicates where the too short and the too long line exist in the file, line 18 is too short and line 30 is too long.
            Best regards from an UC/UE/UES for Windows user from Austria

            11327
            MasterMaster
            11327

              Aug 25, 2017#6

              Dear Mofi!
              THANK YOU SO MUCH for this answer, as usual complete and very useful.
              It's impossible to lead us astray for we don't care even to choose the way.