Text file search and replace using lookup table
-
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.
-
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
-
@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!!!
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