Pash1986 commited on
Commit
3ba8dc5
1 Parent(s): cf4d742

Delete ingest.py

Browse files
Files changed (1) hide show
  1. ingest.py +0 -35
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 = 'sample_mflix'
11
- collection_name = 'embedded_movies'
12
-
13
- embedded_movies_collection = client[db_name][collection_name]
14
-
15
- dataset = load_dataset("AIatMongoDB/embedded_movies")
16
-
17
- insert_data = []
18
-
19
- for movie in dataset['train']:
20
- doc_movie = json_util.loads(json_util.dumps(movie))
21
- insert_data.append(doc_movie)
22
-
23
- if len(insert_data) == 1000:
24
- embedded_movies_collection.insert_many(insert_data)
25
- print("1000 records ingested")
26
- insert_data = []
27
-
28
- if len(insert_data) > 0:
29
- embedded_movies_collection.insert_many(insert_data)
30
- insert_data = []
31
-
32
- print("Data Ingested")
33
-
34
-
35
-