nightroman / Mdbc

MongoDB Cmdlets for PowerShell
Apache License 2.0
141 stars 16 forks source link

import data from CSV format #67

Closed Stephanevg closed 2 years ago

Stephanevg commented 3 years ago

Hi,

Small question. I might have missed it when reading through the help of import-mdbcdata, but is it possible to import data that is contained in a csv file (using import-csv) and / or directly from CSV input (using ConvertFrom-Csv) ?

I found the following example in the help

@{ p1 = 'Name1'; p2 = 42 }, @{ p1 = 'Name2'; p2 = 3.14 } | Export-MdbcData test.bson
    Import-MdbcData test.bson -As PS

do we 'have' to export the data into a bson format before? Is there perhaps a more direct way to import csv files ?

nightroman commented 3 years ago

Sorry for the delay (vacation).

do we 'have' to export the data into a bson format before? Is there perhaps a more direct way to import csv files ?

I do not think so. When you import from CSV, you get so called PS custom objects. They may be used as input for Mdbc cmdlets as they are. No intermediate conversion/export/import to BSON or Mdbc dictionary is needed.