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/
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
https://docs.mongodb.com/manual/reference/program/mongoimport/
댓글
댓글 쓰기