associate_id_ovi_json.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. #%%
  2. import json
  3. import csv
  4. from tkinter import W
  5. # %%
  6. file_lemmario = open ('/Users/leonardocanova/Library/CloudStorage/OneDrive-UniversityofPisa(1)/Documenti/Progetti università/OVI/Programmazione/OVI/power_lemmarioD.json')
  7. lemmario = json.load (file_lemmario)
  8. # %%
  9. print (lemmario)
  10. # %%
  11. file_link = open ('/Users/leonardocanova/Library/CloudStorage/OneDrive-UniversityofPisa(1)/Documenti/Progetti università/OVI/Programmazione/OVI/base2_clean.csv')
  12. link_reader = csv.DictReader (file_link)
  13. # %%
  14. link = [line for line in link_reader]
  15. print (link)
  16. # %%
  17. for lemma in lemmario:
  18. forma_standard = lemma ['lemma']['forma_standard']
  19. filtered_links = list(filter (lambda el : el['sLemma_clean'] == forma_standard, link))
  20. uris = list(map (lambda el : el ['FileHTM'], filtered_links))
  21. lemma ['lemma']['uri'] = uris
  22. # %%
  23. print (lemmario)
  24. # %%
  25. file_lemmario_linked = open ('/Users/leonardocanova/Library/CloudStorage/OneDrive-UniversityofPisa(1)/Documenti/Progetti università/OVI/Programmazione/OVI/power_lemmarioD_link.json', 'w')
  26. json.dump (lemmario, file_lemmario_linked, indent=2)
  27. file_lemmario.close ()
  28. file_lemmario_linked.close()
  29. # %%