Help with Importing from CSV file

7 posts by 4 authors in: Forums > CMS Builder
Last Post: April 30, 2010   (RSS)

By zip222 - April 26, 2010

I have a fairly large list of classes that I need to enter for a new website. I was wondering if there is a way to import this information from an existing Excel or CSV file rather than entering it manually. While I am fairly experienced with CMS Builder and PHP, my knowledge of MySQL Databases is pretty limited.

thanks.

Re: [ross] Help with Importing from CSV file

By zip222 - April 27, 2010

There are some complexities in the details of this that I think are going to make this difficult to do through the forum. I am going to submit a priority consulting request instead.

thanks.

Re: [zip222] Help with Importing from CSV file

By Damon - April 27, 2010

Thanks!

I have your email now so we can discuss the requirements further via email/phone.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] Help with Importing from CSV file

By Toledoh - April 27, 2010

Hi Guys.

If possible, it would be great to get a step by step for importing a CSV - even just the basics?
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] Help with Importing from CSV file

By Damon - April 30, 2010

Hi Tim,

Importing data from a CSV file can be very tricky.

Some methods:
1. Manually add your CSV data into MySQL INSERT statements.

2. Parse the CSV file with custom programming.

Here are some tips for manually inserting data:
- backup your database
- open your database backup and you will see examples of INSERT statements
- create one insert statement and try it out
- use the free MySQL Console plugin to execute your MySQL queries:
http://www.interactivetools.com/add-ons/detail.php?MySQL-Console-1011

Here is an example INSERT:
INSERT INTO `#TABLE_PREFIX#_news` VALUES("1","2010-04-13 21:37:29","1","2010-04-13 21:37:29","1","1271194649","Hello World","2010-04-13 00:00:00","<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sodales viverra lacus, non ullamcorper mi posuere non. t</p>");
- replace #TABLE_PREFIX#_ with your actual mysql table prefix. You can find that in Admin > General Settings -
Database Settings

This is based on the following fields in a News section:
num
createdDate
createdByUserNum
updatedDate
updatedByUserNum
dragSortOrder
title
date
content

- num - needs to be unique
- *ByUserNum - needs to match a user number
- all the Dates need to be in the correct format. If you are not sorting by date, you can use a date from your backup.
- and there may be other requirements based on your fields and setup.

Give this a try by first testing with one or two INSERT statements after you have backed up your database.

As I mentioned, this is tricky and can be tedious.

Hope that helps a little.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] Help with Importing from CSV file

By Toledoh - April 30, 2010

Thanks Damon - I'll give it a try.
Cheers,

Tim (toledoh.com.au)