Beispiel #1
0
def main():
    if len(sys.argv) < 3:
        print 'Usage: %s TXT NICKNAMES' % os.path.basename(sys.argv[0])
        sys.exit(1)
    filename = sys.argv[1]
    nicks = Nicknames(sys.argv[2])
    country = _country_name(filename)
    outfilename = '%s%s%sPovertyLines.sql' % (country.capitalize(), nicks.year(country), nicks.questionsVersionText(country, ''))
    with open(outfilename, 'w') as f:
        f.write('\n'.join(inserts(filename, nicks)) + '\n')
Beispiel #2
0
def main():
    if len(sys.argv) < 3:
        print 'Usage: %s TXT NICKNAMES' % os.path.basename(sys.argv[0])
        sys.exit(1)
    filename = sys.argv[1]
    nicks = Nicknames(sys.argv[2])
    country = _country_name(filename)
    outfilename = '%s%s%sPovertyLines.sql' % (
        country.capitalize(), nicks.year(country),
        nicks.questionsVersionText(country, ''))
    with open(outfilename, 'w') as f:
        f.write('\n'.join(inserts(filename, nicks)) + '\n')
Beispiel #3
0
        if '.' not in line.strip() and line.strip().isdigit():
            answers[-1] = (answers[-1], int(line.strip()))
        if 'Total score' in line:
            yield (question, answers)
            return


if __name__ == '__main__':
    if len(sys.argv) < 3:
        print 'Usage: %s TXT NICKNAMES' % os.path.basename(sys.argv[0])
        sys.exit(1)
    filename = sys.argv[1]
    country_name = os.path.basename(filename.split()[0])
    if '.' in country_name:
        country_name = country_name.split('.')[0]
    nicks = Nicknames(sys.argv[2])
    year = nicks.year(country_name)
    title = nicks.questionsTitle(country_name)
    qs = list(parse_questions(filename))

    xml_country_version = country_name.upper() + str(
        year) + nicks.questionsVersionText(country_name, '')

    properties_out = properties(qs, country_name, nicks, title,
                                xml_country_version)
    sql_out = sql(qs, country_name, nicks, title)
    xml_out = xml(qs, country_name, nicks, title)

    tmp_sql_filename = 'generated/scoringEtl/%s%s%sPPIScore.sql' % (
        country_name.capitalize(), year,
        nicks.questionsVersionText(country_name, ''))
Beispiel #4
0
            letter = letter_it.next()
        if '.' not in line.strip() and line.strip().isdigit():
            answers[-1] = (answers[-1], int(line.strip()))
        if 'Total score' in line:
            yield (question, answers)
            return

if __name__ == '__main__':
    if len(sys.argv) < 3:
        print 'Usage: %s TXT NICKNAMES' % os.path.basename(sys.argv[0])
        sys.exit(1)
    filename = sys.argv[1]
    country_name = os.path.basename(filename.split()[0])
    if '.' in country_name:
        country_name = country_name.split('.')[0]
    nicks = Nicknames(sys.argv[2])
    year = nicks.year(country_name)
    title = nicks.questionsTitle(country_name)
    qs = list(parse_questions(filename))

    xml_country_version = country_name.upper() + str(year) + nicks.questionsVersionText(country_name,'')

    properties_out = properties(qs, country_name, nicks, title, xml_country_version)
    sql_out = sql(qs, country_name, nicks, title)
    xml_out = xml(qs, country_name, nicks, title)

    tmp_sql_filename = 'generated/scoringEtl/%s%s%sPPIScore.sql' % (country_name.capitalize(), year, nicks.questionsVersionText(country_name,''))
    with open(tmp_sql_filename, 'w') as sql_f:
        sql_f.write(sql_out)
    print 'SQL written to ' + tmp_sql_filename