Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import xml.etree.ElementTree
- tree = xml.etree.ElementTree.parse('output501-550.xml')
- e = tree.getroot()
- for article in e.findall('Article'):
- child = xml.etree.ElementTree.Element("Organization")
- if article[2].text != '-':
- email = re.search(r'([A-Z][^\s,.]+[.]?\s[(]?)*(Centro|Associates|Station|Dept|Département|Departamento|Branch|Agency|Limited|Pharmaceutica|Ltd|MRC|Unit|Administration|Division|Inc|Incorporation|Commission|Corp|Corporation|Council|Foundation|Consultants|Board|Association of|Association|Pharmaceuticals|Office of|Office|Labs|Society|Hospital|hôpital|Hôpital|University|University of|Université|Universidad|Institute|Institut|Instituto|Istituto|Universität|Law School|Academy|College|Center|Centre|Laboratory|Laboratoire|Laboratories|Laboratorio|Department of|Department|Clinic|Univ|Bureau of|Research|for Research|Instytutu|Centrum|Ministry of|Company)[^,\d]*(?=,|\d)', article[2].text).group()
- child.text = email
- else:
- child.text = '-'
- article.insert(4,child)
- tree.write("output501-550.xml")
- print("completed")
Add Comment
Please, Sign In to add comment