@@ -0,0 +1,1365 @@
+import os%0Afrom models import db, Subset%0A# importing from admin rather than db, because it needs app context%0Afrom admin import app%0A%0A%0Aif __name__ == '__main__':%0A%0A     # http://stackoverflow.com/a/19008403/2115409%0A     db.init_app(app)%0A     with app.app_context():%0A        # Extensions like Flask-SQLAlchemy now know what the %22current%22 app%0A        # is while within this block. Therefore, you can now run........%0A        # db.create_all()%0A        # change to the right folder%0A        os.chdir('/Users/johan/projects/annotation/data/annotation/output/DNov/textract/')%0A%0A        os.listdir(os.curdir)%0A%0A        for folder in os.listdir(os.curdir):%0A            for input_file in os.listdir(folder):%0A                # parse the file names, fi. BH_non_suspended_quotes.txt%0A                name = input_file.split('_')%5B0%5D  # BH%0A                # BH_non_suspended_quotes.txt -%3E #  BH_non_suspended_quotes%0A                # -%3E #  non suspended quotes%0A                kind = input_file.split('.')%5B0%5D.split('_')%5B1:%5D%0A                kind = '-'.join(kind)%0A%0A                with open(folder + '/' + input_file) as input:%0A                    contents = input.readlines()%0A                    print name, kind, len(contents)%0A%0A                    for itm in contents:%0A                        db.session.add(Subset(book=name, abbr=name, kind=kind, text=itm))%0A%0A        db.session.commit()%0A

Add script to populate the Subset table