def stats_csv_to_mongo():
    path = os.path.join(os.getcwd(), 'data/stats')
    print(path)
    for file, collection in files.items():
        Database.delete(collection)

        data = pd.read_csv(os.path.join(path, file))
        data_dict = data.to_dict('records')

        Database.insert(collection, data_dict)
Exemplo n.º 2
0
def delete(email,blogtitle,blog_id):
    loginform = LoginForm()
    if session['user'] == email and blog_id.__len__() ==  32:
        ids = Users.id_one(blog_id)["_id"]
        if blog_id == ids:
            Database.delete("blogs",{"_id":blog_id})
            flash("blog deleted")
            return redirect(url_for('login'))
        else:
            flash("not right")
            return redirect(url_for('login'))
    return redirect(url_for('login'))
Exemplo n.º 3
0
def insert_csv_to_mongo():
    file_path = os.path.join(os.getcwd(), 'data/covid')

    for file, collection in files.items():
        # delete all documents in the collection
        Database.delete(collection)

        # read csv files saved locally and convert to dict using 'records' parameter
        data = pd.read_csv(os.path.join(file_path, file))
        data_dict = data.to_dict('records')

        # insert models dict into collection
        Database.insert(collection, data_dict)