Datasets:
Delete ingest
Browse files- ingest/ingest.py +0 -35
- ingest/requirements.txt +0 -2
ingest/ingest.py
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
from pymongo import MongoClient
|
3 |
-
import datasets
|
4 |
-
from datasets import load_dataset
|
5 |
-
from bson import json_util
|
6 |
-
|
7 |
-
|
8 |
-
uri = os.environ.get('MONGODB_ATLAS_URI')
|
9 |
-
client = MongoClient(uri)
|
10 |
-
db_name = 'whatscooking'
|
11 |
-
collection_name = 'restaurants'
|
12 |
-
|
13 |
-
restaurants_collection = client[db_name][collection_name]
|
14 |
-
|
15 |
-
dataset = load_dataset("AIatMongoDB/whatscooking.restaurants")
|
16 |
-
|
17 |
-
insert_data = []
|
18 |
-
|
19 |
-
for restaurant in dataset['train']:
|
20 |
-
doc_restaurant = json_util.loads(json_util.dumps(restaurant))
|
21 |
-
insert_data.append(doc_restaurant)
|
22 |
-
|
23 |
-
if len(insert_data) == 1000:
|
24 |
-
restaurants_collection.insert_many(insert_data)
|
25 |
-
print("1000 records ingested")
|
26 |
-
insert_data = []
|
27 |
-
|
28 |
-
if len(insert_data) > 0:
|
29 |
-
restaurants_collection.insert_many(insert_data)
|
30 |
-
insert_data = []
|
31 |
-
|
32 |
-
print("Data Ingested")
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ingest/requirements.txt
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
pymongo
|
2 |
-
datasets
|
|
|
|
|
|