BP2024/annotation_app/initial.py

26 lines
601 B
Python
Raw Permalink Normal View History

2024-04-09 13:39:11 +00:00
from models import db, Samples
from app import app
import json
import os
if __name__ == '__main__':
with app.app_context():
# db.init_app(app)
# creating database
db.create_all()
try:
with open(os.path.join('dataset', 'final_id_v2.jsonl'), encoding='utf-8') as file:
2024-04-11 15:31:10 +00:00
for line in file:
data = json.loads(line)
db.session.add(Samples(data['text']))
2024-04-09 13:39:11 +00:00
db.session.commit()
print('Data sucessfully inserted')
except FileNotFoundError as err:
print(err)