Are there tools that I'm missing out on for mass manipulation of JSON files?
As an example I just modified a bunch of tags to eliminate a Kepware server. So I needed to change the "opcItemPath" to point to the PLC address (e.g. "B3:1/11") and not the name (e.g. "Tag0") that was assigned in Kepware. The find/replace needs to be limited to the "opcItemPath" because the same string is in the "name" key and that should remain "Tag0"
This is how I did it:
- Export the ignition tags .JSON
- Create a simple text file (.csv) to map the replacements.
- Write a python script to:
*Open and read the .JSON
*Open the text file containing the name/address pairs and store in a pandas datatype
*Iterate through the datatype using the replace() function to swap the address for name.
*Write to a new .JSON - Import the new .JSON into Ignition
It worked but I have the following issues:
- The python script took a long time for me to write (due to my incompetence)
- I prepended text to the tag name. This was to limit it to the "opcItemPath" but not the "name" key. Seems kludgy vs directly limiting my actions to a single key/value pair.
How would you accomplish this? My script took a long time to complete my script. Much longer than manually changing the tags although I knew that going into it and embraced it for experience to build competence in scripting. I'm much more of an Excel head and if this was a two-dimension table instead of a JSON I would have cranked out a hot mess of xlookup() and concatenate() functions and had a new file in less than five minutes.
How would complete the same task? Am I on the right path and just need to improve my python skill set? Are there better tools to work with .JSON on Windows OS? Bonus points for something with a GUI for idiots like me.