{"id":20551696,"url":"https://github.com/clarketm/csv-2-mongo","last_synced_at":"2025-04-14T11:32:51.098Z","repository":{"id":86955229,"uuid":"161243905","full_name":"clarketm/csv-2-mongo","owner":"clarketm","description":"Import a CSV to MongoDB","archived":false,"fork":false,"pushed_at":"2019-01-13T07:12:50.000Z","size":136,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T00:44:18.896Z","etag":null,"topics":["csv","csv-2-mongo","import","mongodb","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clarketm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-10T22:20:18.000Z","updated_at":"2023-11-08T12:57:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"f3a90bda-b7fa-4ea4-b263-0b5bc0407c73","html_url":"https://github.com/clarketm/csv-2-mongo","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarketm%2Fcsv-2-mongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarketm%2Fcsv-2-mongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarketm%2Fcsv-2-mongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarketm%2Fcsv-2-mongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clarketm","download_url":"https://codeload.github.com/clarketm/csv-2-mongo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248872039,"owners_count":21175339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","csv-2-mongo","import","mongodb","python"],"created_at":"2024-11-16T02:33:06.870Z","updated_at":"2025-04-14T11:32:51.089Z","avatar_url":"https://github.com/clarketm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [csv-2-mongo](https://pypi.org/project/csv-2-mongo/)\n\n[![PyPi release](https://img.shields.io/pypi/v/csv-2-mongo.svg)](https://pypi.org/project/csv-2-mongo/)\n[![Downloads](https://pepy.tech/badge/csv-2-mongo)](https://pepy.tech/project/csv-2-mongo)\n\nImport a CSV to MongoDB using Python 🐍.\n\n## Installation\n\n```bash\n$ pip install csv-2-mongo\n```\n\n## Usage\n\n```text\n\nUsage: csv_2_mongo.py [OPTIONS] FILE\n\n  Import a csv FILE to MongoDB\n\nOptions:\n  -h, --help             Show this message and exit.\n  -v, --version          Show the version and exit.\n  -d, --database name    Database name.  [default: test]\n  -c, --collection name  Collection name.  [default: test]\n  -H, --host host        Host name.  [default: 0.0.0.0]\n  -p, --port port        Port number.  [default: 27017]\n  -t, --timeout sec      Connection timeout (seconds).  [default: 5]\n  -f, --force            Overwrite collection if exists.\n  -y, --yes              Automatic yes to prompts.\n\n```\n\n\u003e Note: CSV headers are **required** to correctly correlate MongoDB `fields` to CSV `fields`. \n\n## Examples\n\nImport `mammals.csv` to a `mammals` collection in the  `animals` database:\n\n```bash\n$ csv-2-mongo -d animals -c mammals ./mammals.csv\n```\n\n```txt\n....................................\nConnecting to 0.0.0.0:27017\n....................................\n\nImport data.csv to database=animals collection=mammals [y/N]? y\nImport complete!\n```\n\nImport `mammals.csv` to a `mammals` collection in the  `animals` database **overwriting the collection if it exists**:\n\n\u003e Note: the `-f, --force` flag will overwrite the collection without a prompt. If the flag is omitted, `csv-2-mongo` will prompt you before operations with potential data loss.\n\n```bash\n$ csv-2-mongo -f -d animals -c mammals ./mammals.csv\n```\n\n```txt\n....................................\nConnecting to 0.0.0.0:27017\n....................................\n\nImport data.csv to database=animals collection=mammals [y/N]? y\nImport complete!\n```\n\nImport `mammals.csv` to a `mammals` collection in the  `animals` database running on *host* **mongo.travismclarke.com** at *port* **27111**:\n\n```bash\n$ csv-2-mongo -d animals -c mammals -H mongo.travismclarke.com -p 27111 ./mammals.csv\n```\n\n```txt\n....................................\nConnecting to mongo.travismclarke.com:27111\n....................................\n\nImport data.csv to database=animals collection=mammals [y/N]? y\nImport complete!\n```\n\nTo skip the prompt (e.g. `Import data.csv to ...`), such as running via a script, one can pass the `-y`, `--yes` flag to force a *yes* response to the confirmation prompt:\n\n\u003e Note: this will not suppress the *overwrite* prompt which still requires the `-f, --force` flag.\n\n```bash\n$ csv-2-mongo -y -d animals -c mammals ./mammals.csv\n```\n\n```txt\n....................................\nConnecting to 0.0.0.0:27017\n....................................\n\nImport complete!\n```\n\n\n## License\n\nMIT \u0026copy; [**Travis Clarke**](https://blog.travismclarke.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarketm%2Fcsv-2-mongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclarketm%2Fcsv-2-mongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarketm%2Fcsv-2-mongo/lists"}