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!!!