Database Reference
In-Depth Information
The following options deserve more explanation:
--headerline : Uses the first line of the file as the list of field names. Note that this applies only
to CSV and TSV formats.
--ignoreblanks : Does not import empty fields. If a field is empty, then a corresponding
element will not be created in the document for that row; if you don't invoke this option, then
an empty element with the column name is created.
--drop : Drops a collection and then re-creates it with data only from this import; otherwise,
the data is appended to the collection.
You also have to specify the database name and the collection name when you use mongoimport to import data
with the -d and -c options, as in the following example:
$mongoimport -d blog -c tagcloud --type csv --headerline < csvimportfile.csv
Exporting Data from MongoDB
The mongoexport utility is similar to mongoimport , but mongoexport , as its name implies, creates export files from
an existing MongoDB collection instead. This is one of the best ways to extract data from your MongoDB instance
in a format that can be read by other databases or spreadsheet applications. Figure 9-4 shows how to use the
mongoexport utility.
 
Search WWH ::




Custom Search