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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 01:04:47
Script start
Timing: Jan 19 2025 01:04:47
Module start 'layout'
Timing: Jan 19 2025 01:04:47
Module start 'content'
Timing: Jan 19 2025 01:04:48
Module end 'content'
Timing: Jan 19 2025 01:04:48
Script end

Main resources:

Total runtime0.8430 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.1563152.6250
Module start 'layout' 0.00630.0038 741.781339.4453
Module start 'content' 0.01010.8314 781.2266608.3438
Module end 'content' 0.84150.0015 1,389.570316.1641
Script end 0.8430  1,405.7344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4072160.0002
Check MTime0.00140.1677160.0001
Mysql Total
Database connection0.00120.145910.0012
Mysqli_queries0.779392.4393680.0115
Looping result0.00080.0979660.0000
Template Total0.802795.220.4013
Template load0.00220.259320.0011
Template processing0.800594.952920.4002
Template load and register function0.00020.027310.0002
states
state_id_array0.00120.137710.0012
state_identifier_array0.00180.208220.0009
Override
Cache load0.00190.2227340.0001
Sytem overhead
Fetch class attribute can translate value0.00090.101530.0003
Fetch class attribute name0.00160.184680.0002
XML
Image XML parsing0.00110.131530.0004
class_abstraction
Instantiating content class attribute0.00000.002080.0000
General
dbfile0.00180.2188210.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs