• Login
Community
  • Login

Sad Person with an XML file and 500 numbers

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
15 Posts 4 Posters 1.5k 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.
  • J
    jjaggii
    last edited by Aug 16, 2019, 12:55 PM

    Hi
    I have been given his XML file…

    <?xml version=“1.0”?>
    <root>
    <batch>
    <sample number=“6153950253” result=“positive” />
    </batch>
    </root>

    …and I have to create 500 rows (easy enough) but I then have to cut and paste 500 unique numbers into the position between the double quotes. I first asked Google my question was sent here. Having had a read I see N++ has a column mode so I am wondering if I can create my rows and paste in my 500 numbers? Failing that is there a way to to do this?
    Thank you.

    A D 2 Replies Last reply Aug 16, 2019, 2:16 PM Reply Quote 0
    • J
      Jim Dailey
      last edited by Aug 16, 2019, 1:48 PM

      @jjaggii You can indeed cut and paste columns of text.

      There are a few ways to make a rectangular selection:

      • Hold down the Alt and Shift keys and then use the arrow keys to expand the selection.
      • Hold down the Alt key, then drag with the Left Mouse button depressed.
      • Use either of the above methods to start the upper corner, say, of a a huge selection; then use the mouse in the scroll bar to drag way down into the document to where you want the selection to end and then hold down Alt and Shift and drag again with the left mouse button.

      Once selected, you can cut, copy, paste as you might expect.

      Also note that you can make a zero-width rectangular selection (dragging the mouse straight up and down or using only the up and down arrow keys) which is sometimes handy.

      Finally, once you have made a rectangular selection, you don’t have to paste–you can simply start typing in text an several lines at once.

      J 1 Reply Last reply Aug 16, 2019, 6:58 PM Reply Quote 0
      • A
        Alan Kilborn @jjaggii
        last edited by Aug 16, 2019, 2:16 PM

        @jjaggii

        I might do it like this:

        Make 500 lines that look like this:

        <sample number=“” result=“positive” />
        

        Should be easy enough with Notepad++'s Duplicate Line capability.

        Then put your caret between the empty quotes on the first one. Hold down shift+alt+downarrow until you get a skinny caret covering the 500 lines.

        Use Notepad++'s Column Editor feature to insert a different number on each line.

        1 Reply Last reply Reply Quote 1
        • D
          dinkumoil @jjaggii
          last edited by dinkumoil Aug 16, 2019, 2:26 PM Aug 16, 2019, 2:21 PM

          @jjaggii

          If it is OK for you to insert consecutive numbers you can do the following:

          1. Delete the value of the number attribute.
          2. Line up the batch node and all its child nodes into one line.
          <?xml version="1.0"?>
          <root>
          <batch><sample number="" result="positive"/></batch>
          </root>
          
          1. Create 500 copies of the batch node line.
          2. Place the cursor between the two quotation marks of the number attribute’s value.
          3. Go to (menu) Edit -> Column Editor.
          4. Select option Number to Insert.
          5. In the edit field Initial number type 1.
          6. In the edit field Increase by type 1.
          7. If you want all numbers having the same number of digits check option Leading zeros.
          8. Select one of the options under Format to set the number format.
          9. Press button OK.

          This will insert the numbers 1 to 500 into all lines till the end of the document, at the column your cursor has been placed initially.

          EDIT: Too late

          1 Reply Last reply Reply Quote 1
          • J
            jjaggii @Jim Dailey
            last edited by Aug 16, 2019, 6:58 PM

            @Jim-Dailey Thanks Jim. I tried your advice with a small sample of six numbers, but instead of inserting one number in each of the 6 rows it inseryed all 6 numbers in each row!

            A 1 Reply Last reply Aug 16, 2019, 7:31 PM Reply Quote 1
            • A
              Alan Kilborn @jjaggii
              last edited by Alan Kilborn Aug 16, 2019, 7:32 PM Aug 16, 2019, 7:31 PM

              @jjaggii said:

              instead of inserting one number in each of the 6 rows it inseryed all 6 numbers in each row!

              You likely did something wrong. I tried @dinkumoil 's (you did mean him, right, not Jim?) instructions and it worked perfectly, here’s a portion of the result I obtained:

              <batch><sample number="1 " result="positive"/></batch>
              <batch><sample number="2 " result="positive"/></batch>
              <batch><sample number="3 " result="positive"/></batch>
              <batch><sample number="4 " result="positive"/></batch>
              <batch><sample number="5 " result="positive"/></batch>
              <batch><sample number="6 " result="positive"/></batch>
              <batch><sample number="7 " result="positive"/></batch>
              <batch><sample number="8 " result="positive"/></batch>
              <batch><sample number="9 " result="positive"/></batch>
              <batch><sample number="10" result="positive"/></batch>
              <batch><sample number="11" result="positive"/></batch>
              <batch><sample number="12" result="positive"/></batch>
              

              If I were doing it for real it seems I would need to follow it up with a regex replacement of ("\d+)\s+(?=") with \1…

              J 1 Reply Last reply Aug 16, 2019, 8:30 PM Reply Quote 0
              • J
                jjaggii
                last edited by Aug 16, 2019, 7:55 PM

                Just discovered that it will only allow one reply every 20 minutes when I was replying directly. I shall therefore reply to all repliers.Firstly, thank you for going to the trouble of replying.

                I first tried Jim’s suggestion. I tried a sample of six rows and attempted to paste 6 numbers, one into each row. However it pasted all 6 numbers into each row.
                I next looked at Alan’s idea. But using the text to insert feels the same as pasting directly into the file. The number to insert does not let me insert my full 10 digit number.

                @dinkumoil My numbers are not consecutive they are random and unique.

                A 1 Reply Last reply Aug 16, 2019, 8:02 PM Reply Quote 1
                • A
                  Alan Kilborn @jjaggii
                  last edited by Alan Kilborn Aug 16, 2019, 8:04 PM Aug 16, 2019, 8:02 PM

                  @jjaggii

                  it will only allow one reply every 20 minutes

                  You shouldn’t have to wait 20 mins between posts any longer.

                  my numbers are not consecutive they are random and unique

                  So you would use a column block selection (select via shift+alt+arrows) to copy your number list, and then paste that inside the empty double quotes on your first line of 500 duplicates. The 500 numbers in the block should then just appear in the right place on each line.

                  J 1 Reply Last reply Aug 16, 2019, 8:36 PM Reply Quote 0
                  • J
                    jjaggii @Alan Kilborn
                    last edited by Aug 16, 2019, 8:30 PM

                    @Alan-Kilborn No, I meant Jim. @dinkumoil’s suggestion involves inserting consecutive numbers. I didnt try his because my numbers are random 10 digits numbers.

                    1 Reply Last reply Reply Quote 0
                    • J
                      jjaggii @Alan Kilborn
                      last edited by Aug 16, 2019, 8:36 PM

                      @Alan-Kilborn Thanks Alan. I’ll have to figure out what I did wrong. Because what you are suggesting, as jim did, Is what I thought I had done. I will report back.

                      1 Reply Last reply Reply Quote 0
                      • J
                        Jim Dailey
                        last edited by Aug 16, 2019, 8:45 PM

                        @jjaggii

                        You need to copy your random numbers using a rectangular copy in notepad++, then paste them where appropriate.

                        If you do a “normal” copy, you won’t get the proper results.

                        A 1 Reply Last reply Aug 16, 2019, 8:52 PM Reply Quote 0
                        • A
                          Alan Kilborn @Jim Dailey
                          last edited by Aug 16, 2019, 8:52 PM

                          @Jim-Dailey said:

                          need to copy your random numbers using a rectangular copy

                          I said:

                          So you would use a column block selection (select via shift+alt+arrows) to copy your number list

                          How many times are we gonna say this?

                          J 1 Reply Last reply Aug 16, 2019, 9:25 PM Reply Quote 0
                          • J
                            jjaggii @Alan Kilborn
                            last edited by Aug 16, 2019, 9:25 PM

                            @Alan-Kilborn Until it sunk in! It just did. Thank you everyone for your input and for putting up with the uneducated.

                            1 Reply Last reply Reply Quote 2
                            • J
                              Jim Dailey
                              last edited by Aug 16, 2019, 9:45 PM

                              @jjaggii

                              Glad you figured it out.

                              Uneducated is not a problem and with desire is a temporary condition, unlike pettiness which requires real effort to overcome.

                              A 1 Reply Last reply Aug 16, 2019, 11:34 PM Reply Quote 1
                              • A
                                Alan Kilborn @Jim Dailey
                                last edited by Aug 16, 2019, 11:34 PM

                                It’s not uneducated nor is it pettiness; it’s simply reading what people take the time to write in responses. If you do that and it still doesn’t work, read it (and try it) again. Of course, sometimes the help is wrong as well, so after a couple of tries and fails it’s probably best to ask. But we’re all about solutions here, and it sounds like you have one, so there we go, another success story. :)

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