Friday, November 8, 2013

Importing data into a MongoDB database using Kettle from a csv file

In a previous post we saw how to import data into a MongoDB database from a cvs file using mongoimport. In this post we will import data into the MongoDB database from a cvs file using Kettle.

This youtube video show how to import data from a text file into MongoDB
http://www.youtube.com/watch?v=Tgyrd1UiQhE

The screen below shows the configuration of the CSV input


The screen below show the configuration of the MogoDB output



The below screen shows the transformation between the CVS file input ->  MongoDB output was created, and run.



Next we will connect to MongoDB, to see if the data has been indeed imported. Connect to the mongo shell

 > use mydbdemo
switched to db mydbdemo
> db.projects.find().toArray()
[
        {
                "_id" : ObjectId("527d4e5e73ca0be1b2bc2504"),
                "ISV Name" : "Oracle",
                "Storage Brand" : "SVC",
                "Project" : "SVC Chubby nodes and Oracle",
                "Owner" : "Mayur"
        },
        {
                "_id" : ObjectId("527d4e5e73ca0be1b2bc2505"),
                "ISV Name" : "Oracle",
                "Storage Brand" : "IBM Tape",
                "Project" : "Oracle backup",
                "Owner" : "Shashank"
        },
        {
                "_id" : ObjectId("527d4e5e73ca0be1b2bc2506"),
                "ISV Name" : "Oracle",
                "Storage Brand" : "V7000",
                "Project" : "Oracle 12c on V7000",
                "Owner" : "Mayur"
        },
        {
                "_id" : ObjectId("527d4e5e73ca0be1b2bc2507"),
                "ISV Name" : "Oracle",
                "Storage Brand" : "DS8870",
                "Project" : "Easy Tier 5 for Oracle",
                "Owner" : "Mayur"
        }
]

We can also import data directly from a Microsoft Excel spreadsheet into MongoDB using Kettle.

No comments: