Community
    • Login

    Replace last value in row with 0

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    search & replaceregexextended chars
    3 Posts 2 Posters 2.6k Views 2 Watching
    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.
    • Daniel HolzmannD Offline
      Daniel Holzmann
      last edited by

      Hi,

      I have a .csv file, which I need to zero out as part of our monthly process. The file has the following structure:

      Year;MPC ID;Company;Unit;Costcode;Name;Headcount
      2017;16699101;12000000;1001;1271120000;N. Jensen ;1
      2017;16699201;12000000;1001;1271120000;N. Jensen ;1
      2017;16699101;2009;5936;2010;A. Fevang ;1
      2017;16699201;2009;5936;2010;A. Fevang ;1
      2017;16699101;2009;4100;3050;L. Halstein ;1
      2017;16699201;2009;4100;3050;L. Halstein ;1
      2017;16699124;2009;4403;2260;K. Basalt ;1
      2017;16699224;2009;4403;2260;K. Basalt ;1
      2017;16699101;2009;92;9010;M. Kalsas ;1
      2017;16699201;2009;92;9010;M. Kalsas ;1
      2017;16699103;2009;3541;2100;B. Fonag ;0.5
      2017;16699203;2009;3541;2100;B. Fonag ;1
      2017;16699101;2009;4403;2260;S. Jørgensen ;0.35
      2017;16699201;2009;4403;2260;S. Jørgensen ;1
      2017;16699101;2009;4403;2260;K. Pedersen ;0.69
      2017;16699201;2009;4403;2260;K. Pedersen ;1

      Currently I copy/paste the content over to Excel where it’s easy for me to apply zeroes in the last column. However I would really like to process this within Notepad++. So how would I replace any ending value ‘;x’ with ‘;0’?

      I have been trying to find relevant examples in the forum, however didn’t succeed to adapt similar solutions for my problem.

      Thank you in advance

      1 Reply Last reply Reply Quote 0
      • Scott SumnerS Offline
        Scott Sumner
        last edited by

        A regular expression replace will work for your situation:

        Find-what box: [\d.]+$
        Replace-with box: 0
        Search mode: Regular expression

        The rough English explanation of the parts of this is:
        [\d.]: look for digit or period in any order
        [\d.]+: look for one or more digits or periods in any order
        [\d.]+$: look for one or more digits or periods in any order at the end of a line

        1 Reply Last reply Reply Quote 1
        • Daniel HolzmannD Offline
          Daniel Holzmann
          last edited by Daniel Holzmann

          That worked like a charm. Thanks a stack Scott. :)
          And also thanks for elaborating. That’ll really help going onwards to getting more acquainted with these strings.

          1 Reply Last reply Reply Quote 1

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors