#!/usr/bin/python
import findYear
+import re
def add_quotes(s):
return '\"'+s+'\"'
terr = 0;
for line in f:
thisline = line
+ thisline = thisline[:-1]
+
if thisline[-2:] == '\r\n':
thisline = thisline[:-2]
if lastline == 'ID:':
thisID = thisline
+
+ if lastline=='Pre-name style:':
+ prens = thisline
+
+ if lastline=='Post-name style:':
+ postns=thisline
+
if lastline == 'Name:':
+ a = re.search(' ([A-Z]+[^a-z])',thisline)
names = thisline.split()
- if len(names)>0:
- notNames = ['Prince','Princess','St']
- if names[0] in notNames:
- firstName = add_quotes(names[1])
- else:
- firstName = add_quotes(names[0])
+
+ if a !=None:
+ name = a.group(1)
+ firstName = name[0] + name[1:].lower()
else:
- firstName = ''
+ if len(names)>0:
+ firstName = names[0]
+ else:
+ firstName = ''
+
thisName = add_quotes(thisline)
if lastline == 'Born:':
yb = findYear.find_year(thisline)
print s
if finishedRecord ==1:
+ if prens!='.':
+ pre = prens+' '
+ else:
+ pre = ''
+ if postns!='.':
+ post = ' '+postns
+ else:
+ post = ''
+ titleName =''
+ if pre!='':
+ titleName += pre + ' '
+ titleName += firstName
+ if post!='':
+ titleName+=post
+ titleName = add_quotes(titleName)
+
+ prens = add_quotes(prens)
+ postns = add_quotes(postns)
+ firstName = add_quotes(firstName)
s = make_insert('people',\
- [thisID,thisName,firstName,thisBorn,yb,\
- thisDied,yd,mb,md,url,picture])
+ [thisID,titleName,firstName,thisBorn,yb,\
+ thisDied,yd,mb,md,url,picture,prens,postns,thisName])
print s
finishedRecord = 0
if lastline == 'Style:':