Beispiel #1
0
        "experience": None,
        "remark": None,
        "image": '',
        "links": None,
        "platform": ''
    }
    complement.update(councilor)
    c.execute(
        '''
        INSERT into councilors_councilorsdetail(councilor_id, election_year, name, gender, party, title, constituency, county, district, in_office, contact_details, term_start, term_end, education, experience, remark, image, links, platform)
        SELECT %(uid)s, %(election_year)s, %(name)s, %(gender)s, %(party)s, %(title)s, %(constituency)s, %(county)s, %(district)s, %(in_office)s, %(contact_details)s, %(term_start)s, %(term_end)s, %(education)s, %(experience)s, %(remark)s, %(image)s, %(links)s, %(platform)s
        WHERE NOT EXISTS (SELECT 1 FROM councilors_councilorsdetail WHERE councilor_id = %(uid)s and election_year = %(election_year)s ) RETURNING id
    ''', complement)


conn = db_settings.con()
c = conn.cursor()
constituency_maps = json.load(open('../constituency.json'))
# insert
for council in [
        '../../data/taitungcc/councilors.json',
        '../../data/mtcc/councilors.json', '../../data/ptcc/councilors.json',
        '../../data/kmc/councilors.json', '../../data/ylcc/councilors.json',
        '../../data/cycc/councilors.json', '../../data/cyscc/councilors.json',
        '../../data/hcc/councilors.json', '../../data/ntcc/councilors.json',
        '../../data/hlcc/councilors.json', '../../data/tycc/councilors.json',
        '../../data/ilcc/councilors.json', '../../data/chcc/councilors.json',
        '../../data/hsinchucc/councilors.json',
        '../../data/tncc/councilors.json',
        '../../data/ntp/councilors_terms.json',
        '../../data/ntp/councilors.json', '../../data/tccc/councilors.json',
    print sitting_dict["uid"]
    vote_count = 1
    pre_match_end = 0
    for match in Namelist_Token.finditer(text):
        vote_seq = str(vote_count).zfill(3)
        vote_dict = {'uid': '%s-%s' % (sitting_dict["uid"], vote_seq), 'sitting_id': sitting_dict["uid"], 'vote_seq': vote_seq, 'date': sitting_dict["date"], 'content': GetVoteContent(text[pre_match_end:match.end()])}
        UpsertVote(vote_dict)
        ref = {'agree': 1, 'disagree': -1, 'abstain': 0}
        for key, value in ref.items():
            if match.group(key):
                for id, councilor_id in common.getIdList(c, common.getNameList(re.sub(u'[、:,:,]', ' ', match.group(key))), sitting_dict):
                    VoteVoterRelation(id, vote_dict['uid'], value)
        vote_count += 1
        pre_match_end = match.end()

conn = db_settings.con()
c = conn.cursor()
election_years = {1: '1969', 2: '1973', 3: '1977', 4: '1981', 5: '1985', 6: '1989', 7: '1994', 8: '1998', 9: '2002', 10: '2006', 11: '2010', 12: '2014'}
election_year = '2010'
county = u'臺北市'
total_text = codecs.open(u"../../../data/tcc/meeting_minutes-%s.txt" % election_year, "r", "utf-8").read()
util = json.load(open('../../util.json'))

Session_Token = re.compile(u'''
    [\s]*
    (?P<name>
        (?P<county>[\W]{1,3}(市|縣))議會
        第(?P<ad>[\d]+)屆
        第(?P<session>[\d]+)次(?P<type>(定期|臨時))大會
        (預備會議暨)?
        第(?P<times>[\d]+)次