Update README.md
Browse files
README.md
CHANGED
@@ -51,23 +51,23 @@ client = MongoClient(uri)
|
|
51 |
db_name = 'your_database_name' # Change this to your actual database name
|
52 |
collection_name = 'devcenter_articles'
|
53 |
|
54 |
-
|
55 |
|
56 |
dataset = load_dataset("MongoDB/devcenter-articles")
|
57 |
|
58 |
insert_data = []
|
59 |
|
60 |
-
for
|
61 |
-
|
62 |
-
insert_data.append(
|
63 |
|
64 |
if len(insert_data) == 1000:
|
65 |
-
|
66 |
print("1000 records ingested")
|
67 |
insert_data = []
|
68 |
|
69 |
if len(insert_data) > 0:
|
70 |
-
|
71 |
insert_data = []
|
72 |
|
73 |
print("Data ingested successfully!")
|
|
|
51 |
db_name = 'your_database_name' # Change this to your actual database name
|
52 |
collection_name = 'devcenter_articles'
|
53 |
|
54 |
+
collection = client[db_name][collection_name]
|
55 |
|
56 |
dataset = load_dataset("MongoDB/devcenter-articles")
|
57 |
|
58 |
insert_data = []
|
59 |
|
60 |
+
for item in dataset['train']:
|
61 |
+
doc = json_util.loads(json_util.dumps(item))
|
62 |
+
insert_data.append(doc)
|
63 |
|
64 |
if len(insert_data) == 1000:
|
65 |
+
collection.insert_many(insert_data)
|
66 |
print("1000 records ingested")
|
67 |
insert_data = []
|
68 |
|
69 |
if len(insert_data) > 0:
|
70 |
+
collection.insert_many(insert_data)
|
71 |
insert_data = []
|
72 |
|
73 |
print("Data ingested successfully!")
|