-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport.py
More file actions
30 lines (17 loc) · 765 Bytes
/
export.py
File metadata and controls
30 lines (17 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from pymongo import MongoClient
from mock_data import *
from utilities import *
cluster = MongoClient("mongodb+srv://sightpp:UCLSightPP2021@sightcluster.ea126.mongodb.net/myFirstDatabase?retryWrites=true&w=majority")
db = cluster["sight"]
collection = db["footfall"]
# Preprocessing insert into database
ff_data = preprocess_for_mongo(total_df)
collection.insert_many(ff_data)
# Requires the PyMongo package.
# https://api.mongodb.com/python/current
collection.update_many({}, [{'$set': {'timestamp': {'$toDate': '$timestamp'}}}])
def insert_to_mongodb(total_df, collection):
data = preprocess_for_mongo(total_df)
collection.insert_many(data)
collection.update_many({}, [{'$set': {'timestamp': {'$toDate': '$timestamp'}}}])
return True