• Login
Community
  • Login

Deleting characters after 30,000 length

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 5 Posters 1.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    Alex Vaughan
    last edited by Apr 24, 2020, 11:20 AM

    Hi all

    I need some guidance - I have a file with 350,000 lines of text I need to copy into Excel. However, some of these lines are longer strings than Excel can handle (32,000+).

    Is there a simple way using a regular expression Find and Replace, or other method, to simply cut any text which is longer than 32,000 characters?

    Thank you!

    A 1 Reply Last reply Apr 24, 2020, 12:05 PM Reply Quote 0
    • A
      Alan Kilborn @Alex Vaughan
      last edited by Apr 24, 2020, 12:05 PM

      @Alex-Vaughan

      There are a few ways. Here’s one:

      Open the Replace dialog by pressing Ctrl+h and then set up the following search parameters:

      Find what box: (?-s)^(.{32000}).+
      Replace with box: \1
      Search mode radiobutton: Regular expression
      Wrap around checkbox: ticked
      . matches newline checkbox: doesn’t matter (because the (?-s) leading off the Find what box contains an s variant)
      Option checkboxes not mentioned are typically not important to the operation, but should in general be unticked.

      Then press the Replace All button.

      A 1 Reply Last reply Apr 24, 2020, 12:32 PM Reply Quote 3
      • A
        Alex Vaughan
        last edited by Apr 24, 2020, 12:31 PM

        That worked - amazing. Thank you Alan :)

        1 Reply Last reply Reply Quote 2
        • A
          Alex Vaughan @Alan Kilborn
          last edited by Apr 24, 2020, 12:32 PM

          @Alan-Kilborn First time on this site, stupid moment - can I recognize your comment as the one that resolved my issue?

          P 1 Reply Last reply Apr 24, 2020, 12:47 PM Reply Quote 2
          • P
            PeterJones @Alex Vaughan
            last edited by Apr 24, 2020, 12:47 PM

            @Alex-Vaughan said in Deleting characters after 30,000 length:

            @Alan-Kilborn First time on this site, stupid moment - can I recognize your comment as the one that resolved my issue?

            The upvote that you did on his post
            e5f51143-2e68-4609-ac86-195eef558cfc-image.png
            is the normal way of indicating an answer that is helpful and/or insightful.

            Unlike some forums, there is no system for saying “this is the one true answer” or “this is the best answer”, because more often than not, the “true” or “best” answer draws from many different replies, not just one.

            1 Reply Last reply Reply Quote 2
            • G
              guy038
              last edited by Apr 24, 2020, 5:43 PM

              Hello, @alex-vaughan, @alan-kilborn, @peterjones and all,

              In this specific case, Alan, instead of storing the 32,000 first characters, of each line, in a group, I think that the \K syntax has a real purpose !

              So, an alternate solution is :

              SEARCH (?-s)^.{32000}\K.+

              REPLACE Leave EMPTY

              Best Regards,

              guy038

              A 1 Reply Last reply Apr 24, 2020, 5:50 PM Reply Quote 1
              • A
                Alan Kilborn @guy038
                last edited by Apr 24, 2020, 5:50 PM

                @guy038

                Ha, well, if it can’t temporarily remember ~32KB of data, we’ve got bigger problems. :-)

                1 Reply Last reply Reply Quote 0
                • M
                  Matt Bennett
                  last edited by Apr 24, 2020, 7:00 PM

                  This is simple with the gnu “cut” utility: (linux/cygwin/wsl)

                  cut -c 1-32000 File.txt > NewFile.txt

                  A 1 Reply Last reply Apr 24, 2020, 7:06 PM Reply Quote 1
                  • A
                    Alan Kilborn @Matt Bennett
                    last edited by Apr 24, 2020, 7:06 PM

                    @Matt-Bennett

                    This is true but probably the OP has no idea what gnu/cut/linux/cygwin/wsl are.
                    As this is a Notepad++ forum, please try to confine answers to techniques within Notepad++ unless there truly is no way to do it with Notepad++.

                    1 Reply Last reply Reply Quote 0
                    9 out of 9
                    • First post
                      9/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors