import csv
import flask
from flask.ext.script import Manager


questions_manager = Manager()

@questions_manager.command
def load(csv_path):
    with open(csv_path, 'r') as csv_file:
        csv_doc = csv.DictReader(csv_file)
        for row in csv_doc:
            print(row['person_cdep_id'])

@@ -54,16 +54,45 @@
 Manager%0A
+from mptracker import models%0A
 %0A%0Aquesti
@@ -163,16 +163,60 @@
 _path):%0A
+    person_matcher = models.PersonMatcher()%0A
     with
@@ -337,17 +337,125 @@
    p
-r
+erson = person_matcher.get_person(row.pop('person_name'),%0A                                               
 int(row
-%5B
+.pop(
 'per
@@ -470,7 +470,265 @@
 _id'
-%5D
+)),%0A                                               strict=True)%0A            row%5B'date'%5D = models.parse_date(row.pop('date'))%0A            question = models.Question(person=person, **row)%0A            models.db.session.add(question)%0A    models.db.session.commit(
 )%0A

save questions from csv to database