Menu

Help replacing something

2007-11-22
2012-11-13
  • Nobody/Anonymous

    Hello,

    I have a little problem, I've got a file with 100k lines and there are lines like:

    <something number="2000" id="312">
    ..
    ...
    ..
    ..
    <something number="2001" id="312">

    My problem is that i need to add to number="2000" 700 so it would be number="2700" and number="2001" would be number="2701". So you get the point.
    And there are 4000 numbers i need to change so is there any way to do that easily with notepad++ replace?
    Thks

     
    • pshute

      pshute - 2007-11-26

      Your data may not be suitable, but another option is to try reading the file into something like MS Excel.  If you tell it that the delimiters are " then it might be able to get those numbers into columns you can operate on.

       
    • Nobody/Anonymous

      Don't think so.

       
    • Harry

      Harry - 2007-11-22

      You can try to align the numbers so you can column select them and use the column editor with incremental number replace (works very well in resource files ;]), but since its 100k lines expect poor performance (if you get to select it as a column that is, the 'something' wil probably make it hard, although you can try to temporarily add a tab infront of the number and set the tabsize high)

      I suppose your file has been generated, maybe you can get another regenerated copy with corrected numbers?
      php?

       
    • DV

      DV - 2007-11-23

      Use AWK or GAWK for this.
      Here is the corresponding AWK program:

      BEGIN {
        ITEM_COUNT = 100
        START_NUMBER = 2700
        FMT = "<something number=\"%ld\" id=\"312\">\n"

        for (i = 0; i < ITEM_COUNT; i++) {
          printf(FMT, i + START_NUMBER)
        }
      }

      Also you can use
      printf(FMT, i + START_NUMBER) > "file.txt"
      in order to print generated string to file "file.txt"