Migrating Oracle Database: Importing Data from a CSV File to MongoDB

In this section we shall transfer data from the wlslog.csv file to MongoDB Server using the mongoimport tool.

  1. Start the MongoDB server with the following command.


MongoDB gets started on localhost on port 27017 as shown in Figure 8-2.

  1. Run the mongoimport tool to transfer data from the wlslog.csv file to the MongoDB Server. The command options are listed in Table 8-2.

  1. Run the following mongoimport command.

mongoimport –db wls –collection wlslog –type csv –fields ID,TIME_STAMP, CATEGORY,TYPE,SERVERNAME,CODE,MSG –file wlslog.csv

As the output indicates, data gets transferred to MongoDB Server from the wlslog.csv file as shown in Figure 8-3. For the 7 lines of input data 7 documents get created in MongoDB Server.

Source: Vohra Deepak (2015), Pro MongoDB™ Development, Apress; 1st ed. edition.

Leave a Reply

Your email address will not be published. Required fields are marked *