CLI and go library for importing data from CSV, JSON or XML files into MongoDB.
go run github.com/romnn/mongoimport/cmd/mongoimport --db-user=root --db-password=example csv <path-to-csv-files>You can also download pre built binaries from the releases page.
For a list of options, run
go run github.com/romnn/mongoimport/cmd/mongoimport csv --helpUsing the tool as a standalone CLI tool is great for quick loading of a few files. However, you might need more fine-grained control over what files are imported into which collection or perform additional pre/post processing (e.g. parsing timestamps). For this use case, we offer a very extensivle and modular API for configuring your imports.
import "github.com/romnn/mongoimport"
// example t.b.aFor more examples, see examples/.
All commits are automatically built and tested via github actions. In order to pass the required checks it is strongly recommended to install the repositories pre commit hooks (assuming you are in the repositories root):
pip install pre-commit invoke bump2version
pre-commit installThe pre commit hooks will run a number of go tools. Try to run pre-commit run --all-files and check for missing tools. You might need to install some of those:
go get -u golang.org/x/lint/golint
go get -u github.com/fzipp/gocycloIn order to be found, make sure to include $GOPATH/bin in your $PATH ($GOPATH has to be set of course like export GOPATH="$HOME/go for example).
Before committing, pre-commit is run to make sure all checks pass!