@@ -0,0 +1,1457 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%0Aimport csv%0Aimport re%0Aimport sqlite3%0Afrom collections import namedtuple%0Aimport sys%0A%0ARecord = namedtuple('Record', %5B'name', 'day_of_birth',%0A                               'month_of_birth', 'series', 'photo_url', 'important'%5D)%0A%0A%0Adef new_record(csv_line):%0A    character_id, name, full_birthday, series, photo, is_important = csv_line%0A%0A    m = re.match('(%5Cd+).(%5Cd+).+', full_birthday)%0A    if not m:%0A        return%0A%0A    day_of_birth, month_of_birth = m.groups()%0A    if day_of_birth == '??' or month_of_birth == '??':%0A        return%0A%0A    return Record(name, int(day_of_birth), int(month_of_birth), series, photo, bool(is_important))%0A%0A%0Aif __name__ == '__main__':%0A    records = %5B%5D%0A%0A    with open(sys.argv%5B1%5D, 'r') as fp:%0A        reader = csv.reader(fp, delimiter=';')%0A        reader.next()%0A%0A        for line in reader:%0A            record = new_record(line)%0A            if record:%0A                records.append(record)%0A%0A    conn = sqlite3.connect(sys.argv%5B2%5D)%0A%0A    with conn:%0A        cursor = conn.cursor()%0A%0A        cursor.execute(%22CREATE TABLE IF NOT EXISTS birthdays(name TEXT, day INTEGER, %22%0A                       %22month INTEGER, series TEXT, photo VARCHAR(255), %22%0A                       %22important BOOLEAN, PRIMARY KEY(name, day, month))%22)%0A%0A        cursor.executemany(%22INSERT OR REPLACE INTO birthdays (name, day, month, series, photo, important) %22%0A                           %22VALUES (?, ?, ?, ?, ?, ?)%22, records)%0A

Load data from modified CSV file.