I trie
Quote:
Originally Posted by moldy
ERROR: No replace function: You must create a Python function named replace in your code
|
It's because it's pure python, not a regex-function.
From your messages, I understood that you knew a little about python, so it was made to be executed in the python command line or in the calibre-debug prompt, by a python program (in a file) or called in interactive mode.
Create your json-file with the dict, then create a file extract.py, put this in it :
Code:
def main():
import json
fname = '/data/temp/beastones.json' # adapt this to your needs
equiv = json.load(open(fname))
if not equiv:
print(f'Problem loading {fname}')
return
print( '|'.join(equiv.keys()))
main()
after adapting the path and name of the json file in the code
Then go to the command line, and type
[if you are on linux:] python3 your/path/extract.py
[if you are on windows:] calibre-debug your\path\extract.py
The function print() will display on command line, with your example:
John|Paul|George|Ringo
Then you may copy-paste it in the find "field" of the search that will make the substitution.
More help on calibre-debug with the option --help