Advertisement
tumaryui

Untitled

Sep 17th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. ged = open('Abdykerimov.ged', 'r')
  2. pl = open('fam.pl', 'w')
  3. idToPerson = {}
  4. cons = []
  5. cur = '-1'
  6. fname = ''
  7. sname = ''
  8. husb = ''
  9. wife = ''
  10. flag = False
  11.  
  12. for line in ged:
  13. if line.find('INDI') != -1:
  14. if cur != '-1':
  15. idToPerson[cur] = [fname, sname]
  16. cur = line[4:9]
  17. if line[2:6] == 'GIVN':
  18. fname = line[7:len(line) - 1]
  19. if line[2:6] == 'SURN':
  20. sname = line[7:len(line) - 1]
  21.  
  22.  
  23. if line[2:4] == '@F':
  24. flag = True
  25. if line[2:6] == 'CHAN':
  26. flag = False
  27. if flag == True:
  28. if line[2:6] == 'HUSB':
  29. husb = line[9:len(line) - 2]
  30. if line[2:6] == 'WIFE':
  31. wife = line[9:len(line) - 2]
  32. if line[2:6] == 'CHIL':
  33. chil = line[9:len(line) - 2]
  34. cons.append([wife, husb, chil])
  35. idToPerson[cur] = [fname, sname]
  36.  
  37. for x, y, z in cons:
  38. x = idToPerson[x]
  39. y = idToPerson[y]
  40. z = idToPerson[z]
  41. pl.write('parent(\'' + x[0] + ' ' + x[1] + '\',\'' + y[0] + ' ' + y[1] + '\',\'' + z[0] + ' ' + z[1] + '\')\n')
  42.  
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement