View Single Post
Old 03-12-2024, 03:16 PM   #13
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 170
Karma: 1497966
Join Date: Jul 2021
Device: N/A
And here is the python code that extracts the keys from the json file, and create the regex to be put in the "find" field

(with your example, this function will print John|Paul|George|Ringo from the json file used by the regex-function. Modify the path of fname accordingly to your needs)

Code:
def get_regex():
    import json
    fname = '/data/temp/beastones.json'
    equiv = json.load(open(fname))
    if not equiv:
        print(f'Problem loading {fname}')
        return
    print( '|'.join(equiv.keys()))
I leave to you the function that creates the json file from your original text file ; if you know a little about python, with those examples or some searches in the net, it should be easy (use the method json.dump to create the json file from the python dict)

Last edited by lomkiri; 03-12-2024 at 03:48 PM.
lomkiri is offline   Reply With Quote