[SOLVED] Tips for removing safely duplicated notes from two very similar notebooks

I finally opted for python as I know it a (little) bit more than any other options.

In order to visualize differences I use :
d = difflib.Differ()
and
diff = d.compare(text1_lines, text2_lines)

With compare it looks like that:

----------------- new comparison of possibly identical notes---------------

+ Le langage du cerveau Lionel Naccache Tête au carré
+ 
  Le système nerveux digestif est important dans la régulation des émotions et dans l'idée de soi.
  
  Nerf pneumo gastrique
  
  Il n'y a pas une région de la conscience. On n'est pas dans la phrenologie.

---------------- end of comparison of possibly identical notes---------------


The codes that I use with many limitations/bugs looks is like that (it though allows to choose which note to keep in the case of very similar notes with the same meaning content quite fast):

import difflib
from joppy.api import Api
api = Api(token='xxxxxxxx')

import getkey

# initializing things
#notebook1 = None
#notebook2 = None
#notebook_of_analizednotes_name = None


#define manually the name of notebooks of interest for merging (name is case sensitive)
#first two notebook where are to be found duplicated notes
notebook1name='Google_keep_desktop'
notebook2name='Google_keep_laptop'
#notebook were will be put the notes that will be kept
notebook_of_analizednotes_name='Google_keep_analized_via_script'
#notebook were will be put notes that in principle should and could be deleted
notebook_of_tobedeletednotes_name='Google_keep_to_be_deleted'

#get the list of id and title of all notebooks
notebooklist=api.get_notebooks(fields='id,title')['items']

#get the four dictionaries of the notebooks with the selected names
#notebookx['id'] will give the id of notebook1
#notebookx['title'] will give the title of notebook1
for notebook in notebooklist:
    if notebook['title']==notebook1name:
        notebook1=notebook
    if notebook['title']==notebook2name:
        notebook2=notebook
    if notebook['title']==notebook_of_analizednotes_name:
        notebook_of_analizednotes=notebook
    if notebook['title']==notebook_of_tobedeletednotes_name:
        notebook_of_tobedeletednotes=notebook
        
print("notebook1 is", str(notebook1),"\n")
print("notebook2 is", str(notebook2),"\n")
print("notebook_of_analizednotes is", str(notebook_of_analizednotes),"\n")
print("notebook_of_tobedeletednotes is", str(notebook_of_tobedeletednotes),"\n")




#for loop on the 100 notes of one notebook that contain duplicated notes
# make a query from the longuest line of the note
for note in api.get_notes(notebook_id=notebook2['id'],fields='id,title,body')['items']:
    # create a list containig all line of the note
    notelines=note['body'].split('\n')
    print("title:",note['title'],"\n","biggest ligne:",max(notelines),"\n")
    #make a search with the longest line of the note 
    q='"'+max(notelines,key=len)+'"'
    print("searching for:",q)
    identicalnotes=api.search(query=q)
    #if query returns 2 or more notes then...
    if len(identicalnotes['items'])==2:
        print("\n\n\n\n\n\n----------------- new comparison of possibly identical notes---------------\n")
        d = difflib.Differ()
        note1=api.get_note(id_=identicalnotes['items'][0]['id'],fields='id,title,body')
        #list of lines of note 1
        text1_lines=note1['body'].splitlines()
        note2=api.get_note(id_=identicalnotes['items'][1]['id'],fields='id,title,body')
        #list of lines of note 2
        text2_lines=note2['body'].splitlines()
        #compare notes and give a representation of the difference beetween notes
        diff = d.compare(text1_lines, text2_lines)

        print('\n'.join(diff))
        print("\n---------------- end of comprison of possibly identical notes---------------\n\n")

        while 1:
            print("""
            choose your option:
            1: note 1 -> analized notebook
               note 2 -> tobedeleted notebook
               analize next note
            2: note 2 -> analized notebook
               note 1 -> tobedeleted notebook
               analize next note
            3: do not modify note and analize next note

               analize next note
            """)
            key = getkey.getkey()
            if key == '1':
                print('note 1 -> analized notebook')
                #move note1 to analized notebook
                api.modify_note(id_=note1['id'], parent_id=notebook_of_analizednotes['id'])
                print('note 2 -> tobedeleted notebook')
                #move note2 to tobedeleted notebook
                api.modify_note(id_=note2['id'], parent_id=notebook_of_tobedeletednotes['id'])
                print('analizing next note')
                break
            elif key == '2':
                print('note 1 -> tobedeleted notebook')
                #move note1 to tobedeleted notebook
                api.modify_note(id_=note1['id'], parent_id=notebook_of_tobedeletednotes['id'])
                print('note 2 -> analized notebook')
                #move note1 to analized notebook
                api.modify_note(id_=note2['id'], parent_id=notebook_of_analizednotes['id'])
                print('analizing next note')
                break
            elif key == '3':
                break