monogoimport.exe 如何跳过 csv 中的第一列和 header 行?
How can monogoimport.exe skip first column and header line in csv?
我需要将 csv 文件导入 mongoDB。
csv 文件包含 3 列,但我只想导入 2 列并跳过第一列和 headers 行。
如果我有:
id, firstName, lastName
1, Joe, Williams
如何只导入 firstName 和 lastName 列并跳过 id 列和 headers 行?
我不想更改 csv 本身。
我正在使用脚本进行导入:
"...\mongoimport.exe" --host __ --username __ --authenticationDatabase ___ --password __ --db __ --collection __--headerline --file MyCsv.csv --type csv --maintainInsertionOrder
谢谢
您可以使用
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')
我需要将 csv 文件导入 mongoDB。
csv 文件包含 3 列,但我只想导入 2 列并跳过第一列和 headers 行。
如果我有:
id, firstName, lastName
1, Joe, Williams
如何只导入 firstName 和 lastName 列并跳过 id 列和 headers 行?
我不想更改 csv 本身。
我正在使用脚本进行导入:
"...\mongoimport.exe" --host __ --username __ --authenticationDatabase ___ --password __ --db __ --collection __--headerline --file MyCsv.csv --type csv --maintainInsertionOrder
谢谢
您可以使用
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')