I am trying to scrape some PLC code from the ’90s for addresses and variable names and put them in a table or dictionary or anything organized.
For example, in the code listing below, I would like to have perhaps a Python dictionary like:
{'%M00023': 'AUTO SEQUNCE ENABLED', '%M04012':'AUTO. OFF P.B.', ... }
and so on.
The code is padded with spaces.
| LOADER
|AUTO AUTO. RESET
|SEQUNCE OFF MODE
|ENABLED P.B. S.S.
|
|%M00023 %M04012 %M01203 %M02079
+--] [--+--] [-----]/[-----------------------------------------------------( )--
| |
|MACHINE|
|IN AUTO|
|PRELOAD|
|PART |
| |
|%M02079|
+--] [--+
Is there an elegant way to do this? I have hundreds of rungs of ladder to do, and doing it by hand will be error-prone.
2