WP CSV to Database Plugin – Import Excel file content into WordPress database (MySQL)

Categories: Wordpress Plugin

WP CSV to Database plugin allows you to insert CSV file content into WordPress database. Useful when you want to bulk upload data from your CSV file (e.g. product details) to the WordPress database (MySQL) in one go.

Download CSV to DB Plugin

If you didn’t know what a  CSV file is then you can learn more from Wikipedia. You can use Microsoft Excel to enter all your data and then save the file as a CSV file.

Many of my WordPress Shopping Cart users have requested me to add an option so that they can bulk upload their product details into the database from a CSV file (really useful when you have hundreds of products). Hopefully this plugin will satisfy that need and in addition you will be able to use it to bulk upload any data into your WordPress database to save you time and effort.

Installation of the Plugin

  • Unzip and Upload the folder ‘wp-csv-to-db’ to the ‘/wp-content/plugins/’ directory
  • Activate the plugin through the ‘Plugins’ menu in WordPress

Usage of the Plugin

Access the plugin’s User Interface in the WordPress dashboard under the “Settings” menu after installation and do the following:

  1. Specify the general options.
  2. Specify the input file (Upload the CSV file or specify the location of a pre-uploaded CSV file)
  3. Hit the “Import to DB” button to import the CSV file content into the database table.

Download Latest Version (v1.1)

Download the CSV to DB plugin.

How to Use This Plugin to Bulk Upload WP eStore Products

How to Use This Plugin to Bulk Upload WP eMember members

Special Note

If the cell values in the CSV file have special characters like apostrophe (‘) or quotes (“) then don’t forget to use a backslash before them (e.g Karen\’s book).

If you have any issues with the plugin please leave a comment below.

  • Share/Bookmark
Tags: CSV to DB, Web development, Wordpress Plugin

Similar posts that you may like

Subscribe to Tips and Tricks HQ to stay informed

twitter_icon

42 Comments (and 5 trackbacks)

  • #1 by Darren (Green Change) on March 24, 2010 - 5:42 pm

    Wow, so simple and yet so useful! I bet people are going to be thinking of all sorts of uses for this plugin.

    Do you have any plans to add bulk-export functionality? Once you have your products uploaded, you might want to edit descriptions etc. It’d be great to be able to bulk-export the data, update it, and then re-upload them.
    Darren (Green Change)´s last blog ..Soil Blockers My ComLuv Profile

  • #2 by admin on March 24, 2010 - 8:07 pm

    Hey Darren, you always have to come up with good ideas, don’t you? :)

    Bulk-export feature sounds very useful… I will put it on my to do list.

  • #3 by Paul on March 25, 2010 - 5:04 am

    Does this add to or overwrite existing items in the database?
    (Having nightmare visions of someone wiping their database by testing a single entry, or ending up with double everything….)

  • #4 by Paul on March 25, 2010 - 5:05 am

    ….how about an ‘undo’ option :-)

  • #5 by admin on March 25, 2010 - 7:14 pm

    @Paul, It only adds the data to the database so your existing data stays intact.

  • #6 by Ed on March 30, 2010 - 9:00 am

    When I hit the button import to database I see the following error,
    INSERT INTO wp_name_table () VALUES (‘Auto Reinigings Produckten zuur ;Velgen reiniger;801110;Velgen Reiniger 750ml ;? 4′,’60;50;0′,’8;0;0′)
    Ed´s last undefined ..If you register your site for free at My ComLuv Profile

  • #7 by admin on March 30, 2010 - 8:57 pm

    @Ed, There seems to be bug in the code for when you don’t specify the “column names”. I have updated it… please download the latest version from this page and give it a go.

  • #8 by Fiz on April 4, 2010 - 7:19 pm

    Im tryin to upload the csv file and it’s coming up with
    ‘There was an error uploading the file, please try again!’

    I’ve converted all ‘ and ” to \’ and \”

    what else do i need to do?

  • #9 by Fiz on April 4, 2010 - 7:26 pm

    I tried uploading the csv file to my server and got these errors:

    Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /wp-content/plugins/wp-csv-to-database/wp-csv-to-db.php on line 27

  • #10 by admin on April 4, 2010 - 9:34 pm

    Hi Fiz, looks like your server does no allow PHP fopen functionality. You can upload the file to your server using a FTP program then use this plugin to import the content into the database. Just specify the URL of the file in the “Specify the file URL ” field after you upload it.

  • #11 by Fiz on April 4, 2010 - 9:43 pm

    thnx admin for getting back to me.
    I tried that and that’s why i got the fopen() error. I FTP’d the file.
    So i guess my server is the cause of the above error :(

  • #12 by Tcodes on April 12, 2010 - 1:22 am

    thank you. i used this plugin imported more than 16000 records into the DB
    Tcodes´s last blog ..Welcome to Tcodes My ComLuv Profile

  • #13 by Kevin Gibson on April 12, 2010 - 10:02 am

    I have a database of gigs listings that I want to be able to add to, but not duplicate. Will this plugin check for duplicate entries?
    Kevin Gibson´s last blog ..Pink My ComLuv Profile

  • #14 by admin on April 13, 2010 - 3:40 am

    Nope, it won’t check for duplicates (you can tweak the code to add this checking).

  • #15 by Kevin Gibson on April 13, 2010 - 10:38 am

    Thanks, I’ll give it a whirl. Currently I’m getting a problem importing to the database, no error code or anything, just a blank screen loads up. Any ideas what could be causing it to do this?

  • #16 by admin on April 14, 2010 - 3:28 am

    Maybe you have too many entries that’s throwing the error so it’s banking out.

    Can you try with a few entries first to see if it goes in fine?

  • #17 by Kevin Gibson on April 14, 2010 - 1:59 pm

    Thanks for the reply, yeah I’ve tried it with just one entry into a table with only one column and I’m getting the same thing, the page loads until just after the end of the left hand menu then nothing else, so no footer either.
    Kevin Gibson´s last blog ..Pink My ComLuv Profile

  • #18 by admin on April 15, 2010 - 3:55 am

    Okay that kind of indicates that the cells have unusual values or the database columns are not matching.

    Can you share the value you are using in the “Column name” field and one row of the data from the CSV file?

  • #19 by Nate on April 18, 2010 - 1:41 am

    I tried to upload the CSV and got this code:

    Warning: fopen(http://My Website.com/wp-content/plugins/wp-csv-to-db/uploads/AD products.csv) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/nmoller/public_html/wp-content/plugins/wp-csv-to-db/wp-csv-to-db.php on line 27

    I tried to upload it a couple different ways and the same thing.

    I read this suggestion but wasn’t sure what it meant:

    Hi Fiz, looks like your server does no allow PHP fopen functionality. You can upload the file to your server using a FTP program then use this plugin to import the content into the database. Just specify the URL of the file in the “Specify the file URL ” field after you upload it.

    Thanks for the help.
    Nate´s last blog ..The Darryl Strawberry Drop-Out on the Apprentice My ComLuv Profile

  • #20 by admin on April 18, 2010 - 10:03 pm

    Basically some server’s block the fopen (file open) functionality for URLs. You can use the relative URL and it should work fine.

    So upload the CSV file in the “uploads” directory of the plugin then use the following in the “Specify the file URL” field:

    uploads/products.csv

    “products.csv” is the name of the CSV file in this example.

  • #21 by George on April 19, 2010 - 2:20 pm

    Great plug-in, works great! I was wondering if it could be changed to work on the user side? For Example, rather than having the options, upload form, and import button on the admin side, have it on a page where users can access it and use the features themselves? I’m sure I could figure it out if it is indeed possible, just don’t want to waste time so i thought I would ask if it is possible. Thanks!

  • #22 by admin on April 20, 2010 - 4:06 am

    It can be easily tweaked to do that but the first concern is security. You should never have an open upload option to your server because the next morning you will wake up and find out that you have lots of junk from all the bots uploading crap. So the question is do you plan to add the upload option on an open page or post?

  • #23 by skaki on April 24, 2010 - 2:02 pm

    I keep getting this error when I am trying to upload the .csv file. I tried FTPing the same file, and I get a long list of errors.

    “There was an error uploading the file, please try again!”

    no details around what the error could potentially be.

    what should I do?
    skaki´s last blog ..At&t Cell Phone Deals – Motorola, Samsung, Sprint & Nokia My ComLuv Profile

  • #24 by admin on April 24, 2010 - 9:36 pm

    “I tried FTPing the same file, and I get a long list of errors” – If you have a lot of entries in your CSV file then there is an error in the row then the same error is going to appear again and again (making it a long list). The best way to handle this is to use CSV file with 1 entry and try to import it (this way you will be able to see what the error is correctly). Once you fix the errors and can import one row fine then use that same format to populate the rest of the entries in the CSV file. Does it make sense?

  • #25 by Carol on May 17, 2010 - 10:39 am

    Is it possible to use this plug-in to bulk-add users to a BuddyPress site? I have more than 2K users to import, and haven’t found a plug-in that will do this.
    Carol´s last blog ..Welcome to The Digital Artist My ComLuv Profile

  • #26 by admin on May 18, 2010 - 6:03 am

    As long as you are uploading into a table in WordPress you can use this plugin. I am pretty sure BuddyPress uses a table inside WordPress database so you should be fine.

  • #27 by Marcus on May 22, 2010 - 9:11 am

    I find this very useful but I don’t know where I can get he details (field names, field types and table names) of the wp-ecommerce plugin. I want to import products to the database and also the location of the product images. Could you please how I can get those details about wp-ecommerce tables? Thanks!

  • #28 by Marcus on May 22, 2010 - 9:12 am

    just correcting the last phrase:
    Could you please tell me how and where I can get those details about wp-ecommerce tables? Thanks!

  • #29 by Marcus on May 22, 2010 - 9:56 am

    Well, I found myself part of the answer. I used the excellent plugin WP-DBManage available at http://lesterchan.net/portfolio/programming/php/ to get the table names. And I’m still researching about getting field names and field types. I’m trying to avoid having to write a page where I’d code a query to the database. Looking for something already done and reliable.
    Thanks.

  • #30 by admin on May 23, 2010 - 12:31 am

    Hi Marcus, You can find all these info from your PHPMyAdmin. So if you log into your cPanel and browse to the PHPMyAdmin you will be able to select your WordPress database. There you can sell all the tables you have and the field names and types of each tables.

  • #31 by Nicolas on June 2, 2010 - 12:30 am

    Plugin seems VERY interesting.

    I was wondering if it was possible to import a “tab” file rather than “CSV” file. I have a lot of “commas” to import from my datas (prices, products descriptions,…) so it seems dificult to use CSV type file.

    Any idea ?

    Thanks
    Nicolas´s last blog ..Novedades y ideas My ComLuv Profile

  • #32 by Nicolas on June 2, 2010 - 12:34 am

    Dear Tipsandtricks

    Thanks for this GREAT idea. I was wondering if it was possible to “erase” a database before importing.
    For example, if I have to update prices, I should first erase all the records and then import the updated prices database.

    Thanks
    Nicolas´s last blog ..Novedades y ideas My ComLuv Profile

  • #33 by admin on June 2, 2010 - 10:06 am

    The plugins uses PHP’s CSV file reading function to read the CSV file so it will have to be a CSV file.

    Just to give you an idea… if you can code then anything is possible. You write your own code which reads a plain text file that delimited by “tab” then when you read it you can split it using the “explode” function where it finds the “tab” character. Then you just prepare a statement with the data and insert it into the database.

    This plugin do not let you delete records it only adds to the database. Again adding an option like this is not hard either.

  • #34 by Claire on June 11, 2010 - 3:09 pm

    I am so happy to have found this plugin. I need it to avoid duplicates though (or actually just deleting the table and replacing with the one I upload would be perfect). How would I tweak the code to make that happen?? I am not a coder so I’d need very explicit directions!!

    THANKS!!

  • #35 by admin on June 11, 2010 - 9:02 pm

    Unfortunately there is no one line tweak that I can give you for this one. It will require a good understand of PHP and MySQL to tweak this.

    I can only give you the explanation. when you read the CSV file line by line you will need to make a database query with the key to see if an entry already exists for that key. If it does then you need to delete that and then continue with the insertion.

  • #36 by Claire on June 11, 2010 - 9:56 pm

    Oh dear! Well a good understanding is something I don’t have :( If anyone else can help me, I’m all ears! Or maybe we could have a button added to the plugin that says “overwrite” table or “ignore duplicates” like there is in myPHPadmin? A suggestion for future releases perhaps?!

  • #37 by click radius on June 13, 2010 - 12:44 am

    This is lovely! But it may need some work for WP 3. My site is having trouble since installing it.

  • #38 by Michael DeLuca on July 2, 2010 - 2:27 pm

    It doesn’t seem to be working for me.

    I’m using plugin version 1.1 on wordpress 2.8.6 with Safari 5. I’m using a file with only one line, as recommended above for testing. And I’m uploading the file using FTP and specifying the url rather than uploading through the plugin. When I click “Import to DB”, I get a response saying “File content has been successfully imported into the database!” But the uploaded product does not appear in the eStore product manager. Nor does the data show up in the database when I check the table with phpMyAdmin. So it doesn’t look like it actually did anything.

  • #39 by Cemal on July 3, 2010 - 3:11 pm

    How does the plugin know to map the CSV fields to DB fields? Should the CSV be structured in a particular way? If so, in what sequence so that all the data will go to the correct field of the eMember DB.
    Cemal´s last blog ..Protected- Member List My ComLuv Profile

  • #40 by admin on July 4, 2010 - 4:07 am

    You need to specify the column names in the “Column Names” field of the plugin. In the CSV file you will need to place your data accordingly so it aligns with the column names.

    How do you find the column names of your database table?

    One way is to log into your PHPMyAdmin from cPanel and browse to the database table that you are after. If you hit the “Browse” or “Structure” you will see it lists all the column names of the table that you copy and paste.

  • #41 by admin on July 5, 2010 - 9:47 pm

    @Michael, Looks like you are using it for eStore plugin. Can you please follow the instruction on this page?

    http://www.tipsandtricks-hq.com/ecommerce/how-to-bulk-upload-estore-products-from-a-csv-file-775

    Don’t even change the product names in the template csv file. Just follow the process step by step and let me know if you get the two test products specified in the template csv file imported into your database (I just checked and it works fine for me).

  • #42 by Adam on August 15, 2010 - 1:51 pm

    I had been struggling with uploading even after fixing the infamous fopen conflict. After hours of struggling and trying over and over, I noticed that the file I was trying to upload had been saved as .xls, not .csv. Just in case anyone else has this happen, make certain Excel saves as csv, not xls.
    Adam´s last undefined ..If you register your site for free at My ComLuv Profile

CommentLuv Enabled

Featured & Popular Articles

Tips and Tricks Hot Items

wordpress_estore_icon
wordpress membership plugin
WordPress PDF Stamper Plugin
WordPress Affiliate Link Manager Plugin
wordpress_affiliate_plugin_icon