Import CSV to Mongo with .Net Mongo-driver using mongoimport

Hi guys, is there any way to use the command or utility “mongoimport” with the .Net Mongo Driver to load a .CSV in mongo atlas for running it in a microservice than read the file in a url or cloud storage.

Thanks for your help.

Hi @Jose_Alejandro_Benit, thanks for your question!

mongoimport is a separate tool that does not depend on or require the use of any driver. You usually use it to load data that’s generated from either mongoexport or some other third-party export tool.

What are you trying to do? Any additional information would be great so that we can point you in the right direction!

Thanks :slight_smile:


Thanks Adrienne, we are trying to import masive records into mongo collections using .net driver or nodejs. Right now we are reading de CSV file row by row and doing a “InsertMany” but we want to know if there is another fastest way to do this load.

Pd. Excuse me for my english.

No worries at all, I understand you @Jose_Alejandro_Benit. :slight_smile:

Thanks for the context around what you’re doing.

A few more questions:

  • Is this a one-time insert of these massive records or are you doing this more frequently?
  • Can you share your code snippet that is doing the inserts?
  • How many documents are you trying to insert/how many records are we talking about?

Thank you! The answers to these questions will help me get a clearer picture of what you’re doing and will help me determine if there are any improvements or changes needed!

1 Like

Thanks Adrienne.

  1. It’s not a one-time insert, we need do it few times a month.
  2. Sure, we did it in NetCore, we read a file, line by line create an object and add it to a list, after that, we send the list to another method to do a bulkinsert using a batchSize.
    (our code is in spanish)

  1. We will try to read/insert about 2 or 3 millions of records by file. We are building an app, here the end-user upload a .csv file and we read the file and create a collection and insert the records.

Again, thanks for your help.