Import csv tsv file into MongDB

When the csv or tsv file has headerline
csv
$ mongoimport -d <database> -u <username> -c <collection> --type csv --headerline --file <filename>

tsv
$ mongoimport -d <database> -u <username> -c <collection> --type tsv --headerline --file <filename>



When the csv or tsv file doesn't have headerline and set field type

$ mongoimport -d <database> -u <username> -c <collection> --type tsv --columnsHaveTypes --fields "name.string(),register.boolean(),phone.int32()"  --file <filename>


https://docs.mongodb.com/manual/reference/program/mongoimport/

댓글

이 블로그의 인기 게시물

mongoDB admin 권한 설정방법 How to enable access control for mongo DB

Install pm2 via yarn globally

Install Nginx on Linux