brandnewbox.co.uk

Home of Andrew Weaver, a uk-based web developer specialised in building high-quality websites

CSVGrab ExpressionEngine plugin

Monday, December 18th, 2006

Andrew Weaver

Category:

Highlights

  • Import data into EE from CSV file
  • Makes batch imports easy

CSVGrab is a variation of one of my other plugins FeedGrab, and allows you to import data from a CSV file into a weblog.

Usage is similar to FeedGrab, the template:

{exp:csvgrab url="http://www.url.co.uk/products.csv"
    weblog="5"
    title="1"
    skip="6"
    delimiter="TAB"
    encloser=""
    use="2|3"
    fields="prod_description|prod_keywords" }

imports a tab delimited CSV file into the weblog with id of 5, skipping the first 6 lines.

It uses column 1 as the title field, and columns 2 and 3 as the custom fields prod_description and prod_keywords.

delimiter is the character that separates the columns, encloser is the character that wraps the column.

eg, “Title”,"Description”,"Keywords" has a comma delimiter and a quote encloser.

EE ‘cleans up’ plugin parameters, so for delimiter and encloser use the following codes rather than the actual character: TAB, SPACE, QUOTE, eg,

delimiter="TAB" encloser="QUOTE" 

A forum thread exists on ExpressionEngine for bug reports, feature requests etc.

Download: EE CSVGrab plugin.

Comments

1. Sue Crocker
4th Jan 2007 at 7:49 am

Great plugin. I used it to import roughly a dozen articles into a client database. I used Access first, then converted to a .csv file.

2. Sue Crocker
13th Jun 2007 at 7:56 am

Hey, Andrew is there any way this plugin could also pass start dates and end dates? I have a bunch of events to put in, and that would be helpful. It would have 2007-06-14 as a text string and the start time would append 00:01 AM for start and 12:59 PM for end time. I don’t need exact time, just the start and ending for a day.

3. Shelagh
12th Jul 2007 at 7:38 am

I keep a record of all my books using software from Collectorz.com I’m in the process of creating an online catalogue of my books using EE and have just imported 500+ books in the blink of an eye!  Thank you very much for this brilliant little plugin :D

4. Engelbert
21st Aug 2007 at 8:03 am

Hello there,

first of all: I must say CSVGrab is a great tool and I’m very happy I found it. I’ve got it working in my app and it imported hundreds and thausands of entries for me.

But there are two tiny problems I’m wondering about if you or anyone in here could help me out with this:

1.) I import data with special characters, for example ”München” -
In my backend I use UTF-8 for character encoding. If I browse through my
backend these characters are displayed like this: ”M?nchen” - and this gets me
confused because I’m not sure if the data was not imported correctly or if the data was just
not displayed correctly due to character spezification. If I switch to ISO-8859-1
in my backend installation, all characters are displayed correctly. That’s fine
but then I’ll get other problems. Anyway....

question Which encoding does SCVGrab use for the import of the data? Can you specify that
in any way? Can I change that - for expamle - to UTF-8 ??

2.) CSVGrab provides you from the import of dublicate data because it checks first, if
there exists an entry with the same title. This is great but not for me.

I have a property consultant data base running on my installation. Consultants
can be located in different towns, that means, that the names of the consultants
(= title) will remain the same, but the category (= town) will differ.

question What do I have to do to filter only dublicate content, if the title AND the
category are the same???

Thanks for any help you can provide.

If you want to take a look on the page I’m talking about go to:

http://www.weko-immobilien.com

It is a multilingual page with content in german, english and frensh. You can switch to a different language using the language navigation on top right of the page.

Thank you again and good night.

5.
12th Sep 2007 at 3:11 am

I cannot get anything to happen. Are we supposed to run the plugin within our normal template that we use to display our weblog output? or are we supposed to run this plug-in as a stand-alone file?  I am assuming we run this once. How? Thanx for your help

© brandnewbox.co.uk 2004-2008