Community
    • Login

    Text file search and replace using lookup table

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 1.2k Views 1 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.
    • nazooks99N Offline
      nazooks99
      last edited by

      Hi all! I need some help on a project at work, and from what I understand what I am looking for could only be done using some Python script, I have some background in programming from years (C/C++) ago but I am lost on how to get started with this project/script as I do not have any experience with Python, but I am aware it is available for use in Notepad++ so I hope someone can help me here.

      What I have is a large text file which has a list of customers identified by a unique identifier starting with “AXX” + a 6-digit number, for example, AXX000001, AXX000002, AXX000003, etc. These IDs are stored in a database, unfortunately, these identifiers are unusable for this project, but I have a second set of identifiers for the same customers (a random alphanumeric string of 10 digits) in an Excel spreadsheet which I have used something like a crossover/lookup table, where column A is the above identifier and column B is the correct ID. On past projects I have been able to use this crossover/lookup table using Excel, but for our current needs I would have to do it manually, one at a time. Could I run a Python script in Notepad++ which would search the text file for any instances of the first ID and do a lookup using the Excel file (could be converted to a CSV or similar text file) to replace the ID found in the text file with the correct ID?

      Hope someone can point me in the right direction! I have been able to use the built-in regex functionality to search/replace on large files like this, but I am totally lost on how to incorporate the crossover/lookup table to this point.

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA Online
        Alan Kilborn @nazooks99
        last edited by

        @nazooks99

        It’s been dealt with before, so I can’t say it is a very interesting topic anymore…

        The PythonScript in this thread may be of interest as it could probably be adapted to deal with your specific version of this problem:

        https://community.notepad-plus-plus.org/topic/23638/massive-list-and-massive-search-and-replace

        nazooks99N 1 Reply Last reply Reply Quote 1
        • nazooks99N Offline
          nazooks99 @Alan Kilborn
          last edited by

          @Alan-Kilborn
          I see, sorry about that, I had searched around but didn’t find what I was looking for, probably didn’t search for the right keywords. This works perfectly, you’re a life saver! Thanks so much!!!

          1 Reply Last reply Reply Quote 3

          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