Last active
November 6, 2021 15:22
-
-
Save 6mini/264b860876ab3f8e532018d424f8b2ea to your computer and use it in GitHub Desktop.
Insert in the csv file MongoDB using Pandas.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from pymongo import MongoClient | |
import json | |
data = json.loads(pd.read_csv('csv.csv').to_json(orient='records')) | |
coll = MongoClient(MONGO_URI)[DATABASE_NAME][COLLECTION_NAME] | |
coll.remove() | |
coll.insert_many(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment