Hello. An example of the script code that I have in js on the screenshots. I have a function in my Python program for searching and replacing words. It is implemented on the frontend. I need an equivalent on the backend. To put it simply, to rewrite this code to backend code. The script in Js is connected to a json file. The json file contains the words to find and replace from and to. For example:
[
{
"from": "2024",
"to": "2025"
}, ]
This script does not work very accurately, sometimes it replaces, sometimes it misses something. And the problem is not in the script itself. To put it simply, in the frontend, there are sometimes escaped tags in the browser, and other issues. In short, various specialists struggled with this script for a long time. And we did a lot with it. Its logic is very good. It's just that the browser can mess up a lot of things. So I thought, why do this in the browser? Through the backend, the data will be processed faster and probably more accurately.
There are words with three letters like "rub" to be replaced with "uah". And it could also make a replacement in the word "aerotube". But! This moment was resolved in the script code. Now the replacement is well defined. Just warning that I will test the equivalent in Python script and it should not be worse than what I currently have. To avoid such problems. The accuracy to the number of characters should be maintained. If the word to be replaced has 3 characters, then we replace it in a word that also has 3 characters and no more and no less. Otherwise, just keep the text as is.
In my browser, I have a button to open a file. For saving, there is a button Save to Excel. The action there is performed by Python, I know for sure. Because various default functions were attached to it. To avoid creating a bunch of buttons in the browser and so on. Therefore, we will attach your code to this button. So that when the file is saved to Excel, the other 10 standard functions are also executed, and we will add your code at the very bottom of the Python code, which will also be activated along with the other functions.
The file saving happens in Excel for me. In other words, you will not need to do anything on the frontend.
Place your code in my code. That's all. Thank you for your attention!