2016-06-22 1 views
0

csvファイルをmongoDBにインポートする必要があります。
csvファイルには3つの列が含まれていますが、2つの列のみをインポートし、最初の列とヘッダー行はスキップします。monogoimport.exeはどのようにしてcsvの最初の列と見出し行をスキップできますか?

私が持っている場合:

id, firstName, lastName 
1, Joe, Williams 

がどのように私は、姓と名の列をインポートし、id列とヘッダ行をスキップすることができますか? 私はcsv自体を変更したくありません。
私は、インポートするスクリプトを使用しています:

"...\mongoimport.exe" --host __ --username __ --authenticationDatabase ___ --password __ --db __ --collection __--headerline --file MyCsv.csv --type csv --maintainInsertionOrder 

おかげ

答えて

1

をあなたがため

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') 
+0

感謝を使用することができますリプレイ。ヘッダー行もスキップできますか? – Shir

+0

@Shirいいえ、mongoはフィールド名と値を一致させる必要があるため – profesor79

関連する問題