Forums / Developer / import csv and create objects

import csv and create objects

Author Message

Darren Mothersele

Tuesday 03 August 2004 6:25:08 am

I have an excel spreadsheet with 3000 lines - all products. I created a class using the admin interface to represent this data.

I want to write a php script that will open the csv, and loop round, saving each entry to the ezpublish database. I was thinking of importing into the database using phpmyadmin - but after searching the docs and forum, the database structure has given me a real headache.

<?php

$lines = file('./testdata.csv');

foreach ($lines as $line_num => $line) {
   $tracks[$line_num] = explode(",", $line);
   //something here to create the ez object and save it to the database?
}
?>

Ekkehard Dörre

Tuesday 03 August 2004 9:59:10 am

Hi,

have a look here:
http://ez.no/community/contributions/import_export
and here
http://ez.no/community/forum/developer/importing_update_entry_if_it_already_exists
and here
http://ez.no/community/forum/developer/import_image_into_existing_class

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Darren Mothersele

Tuesday 03 August 2004 10:29:08 am

thanks, i'm inspecting the code now to see if i can finally understand how this thing works!

i think i've finally worked out the database structure... but i'm sure it's a really bad idea to try and add objects manually.

Darren Mothersele

Monday 09 August 2004 10:24:16 am

this is great! I've had some success importing objects using a script i downloaded from one of those links.

I'm stuck on another part, I was hoping someone had an idea how to acheive this...

I am importing an object that has an Object Relation List as one of the attributes. How do I create a new object from some of the import attibutes, and add this to the relation list? I looked at the code for the ezobjectrelationlist type - but i can't work out which method i need to use - and there's no documentation on this.

Thanks,

--Darren

Darren Mothersele

Tuesday 10 August 2004 11:02:49 am

i've come up with a solution - not exactly what i wanted, but i think it will work.

I'm adding the objects as child nodes under the object - rather than using the object relation list.

Siniša Šehović

Friday 27 August 2004 12:59:44 am

Hi Darren,

Can you please email me your script to see what and how did you do it?

Best regards,
Sinisa

---
If at first you don't succeed, look in the trash for the instructions.