I need to import csv file into mongoDB.
The csv file contain 3 columns, but I want to import only 2 columns and skip the first column and the headers line.
If I have :
id, firstName, lastName
1, Joe, Williams
How can I import only the firstName and lastName columns and skip the id column and the headers line?
I don't want to change the csv itself.
I am using script for the import:
"...\mongoimport.exe" --host __ --username __ --authenticationDatabase ___ --password __ --db __ --collection __--headerline --file MyCsv.csv --type csv --maintainInsertionOrder
Thanks
You can use
mongoimport /fields:firstName, lastName ///***/// add your optons here
mongoimport.exe --help
input options:
/f, /fields:<field>[,<field>]* comma separated list of field
names, e.g. -f name,age
/fieldFile:<filename> file with field names - 1 per
line
/file:<filename> file to import from; if not
specified, stdin is used
/headerline use first line in input
source as the field list (CSV
and TSV only)
/jsonArray treat input source as a JSON
array
/type:<type> input format to import: json,
csv, or tsv (defaults to
'json')