I have a data collection, which is separated by |
character. I am going to add the data collection to mongodb. So I need to separate data through |
character. how my mongoimport command looks like?
Previously, I'm successfully import csv file through the following command.
$ mongoimport -d mydb -c things --type csv --file locations.csv --headerline
Simply put: a delimiter is the character that separates fields in your CSV file. It is what the computer reads as a "separator" of sorts, giving structure to your file.
The simplest way to import a single file into MongoDB is to use the --file option to specify a file. In my opinion, the very best situation is that you have a directory full of JSON files which need to be imported.
A CSV file stores data in rows and the values in each row is separated with a separator, also known as a delimiter. Although the file is defined as Comma Separated Values, the delimiter could be anything. The most common delimiters are: a comma (,), a semicolon (;), a tab (\t), a space ( ) and a pipe (|).
mongoimport
supports either JSON, CSV (comma separated values) or TSV (tab separated values). The |
character is not a valid delimiter for either CSV or TSV, so you will need to change your input files' |
to ,
or a tab, and specify --type
accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With