Skip to content

Instantly share code, notes, and snippets.

View shashwata27's full-sized avatar
🎯
Focusing

Shashwata Saha shashwata27

🎯
Focusing
View GitHub Profile
@shashwata27
shashwata27 / pandas_labeled_csv_import_to_mongo.py
Last active February 21, 2024 20:32 — forked from jxub/pandas_labeled_csv_import_to_mongo.py
A simple mongoimport for importing csv files with python and pymongo
import pandas as pd
from pymongo import MongoClient
import json
def mongoimport(csv_path, db_name, coll_name, db_url='localhost', db_port=27000)
""" Imports a csv file at path csv_name to a mongo colection
returns: count of the documants in the new collection
"""
client = MongoClient(db_url, db_port)
db = client[db_name]