Importing and Exporting MongoDB Data


Studio 3T greatly simplifies the process of importing and exporting MongoDB data.

It provides the Import Wizard for retrieving document data from different sources, including .json files, .csv files, mongodump folders and archives, and other MongoDB collections.

Most tasks within the wizard are simple point-and-click operations that control the source and target parameters for importing data.

For example, to import a .json file, you navigate to the source file, select the target database and collection, and select an insertion option, which determines how _id values are handled. Studio 3T does the rest.

In some cases, you might also need to export document data, which Studio 3T also helps to simplify.

Studio 3T also provides the Export Wizard for easily exporting data to .json files, .csv files, mongodump folders or archives, and other collections, even if they’re located in different MongoDB databases or environments.

For example, you can export a collection from a database on a local instance of MongoDB Server to a database on MongoDB Atlas, or vice versa. In addition, you can control how the data is exported, such as specifying which character to use to delimit values when saving the data to a .csv file.

Studio 3T also simplifies the process of importing data from SQL-based relational databases and exporting data to those databases. For SQL-related operations, you can use such tools as SQL to MongoDB Migration or MongoDB to SQL Migration, which we’ll explore in future courses.

In this tutorial, you’ll create a database in MongoDB and import document data into the database from a .csv file that contains information about British pubs.

After importing the data, you’ll build a simple query that limits the collection’s data to pubs in Scotland.

From there, you’ll export the query results to a .json file and then export the same results to a collection in a separate database, which you’ll also create as part of this tutorial.

By the end of this section, you will learn how to:

  • Import document data from a .csv file
  • Export document data to a .json file
  • Export document data to a new collection

What you will need:

  • Access to a MongoDB Atlas cluster
  • Ability to download a .csv file from the Internet

Additional resources: 

Log in

Log in to your Studio 3T Academy account

Forgot password?

Don't have an account yet? Sign up
Sign up

Start learning MongoDB today. All fields are mandatory.

By signing up for a course, you agree to the 3T Software Labs Privacy Policy.

Already have an account? Log in