ajosh0504 commited on
Commit
05c49c2
·
verified ·
1 Parent(s): e4c054b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +6 -6
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
- product_collection = client[db_name][collection_name]
55
 
56
  dataset = load_dataset("MongoDB/devcenter-articles")
57
 
58
  insert_data = []
59
 
60
- for product in dataset['train']:
61
- doc_product = json_util.loads(json_util.dumps(product))
62
- insert_data.append(doc_product)
63
 
64
  if len(insert_data) == 1000:
65
- product_collection.insert_many(insert_data)
66
  print("1000 records ingested")
67
  insert_data = []
68
 
69
  if len(insert_data) > 0:
70
- product_collection.insert_many(insert_data)
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!")