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.

eZ debug

Timing: Jan 31 2025 04:34:07
Script start
Timing: Jan 31 2025 04:34:07
Module start 'content'
Timing: Jan 31 2025 04:34:07
Module end 'content'
Timing: Jan 31 2025 04:34:07
Script end

Main resources:

Total runtime0.2128 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 587.9297180.8359
Module start 'content' 0.00520.0102 768.765697.9922
Module end 'content' 0.01540.1973 866.7578526.2734
Script end 0.2127  1,393.0313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00351.6547200.0002
Check MTime0.00130.6047200.0001
Mysql Total
Database connection0.00070.329910.0007
Mysqli_queries0.149170.03761410.0011
Looping result0.00130.63211390.0000
Template Total0.196792.410.1967
Template load0.00090.416810.0009
Template processing0.195892.011510.1958
Override
Cache load0.00060.296910.0006
Sytem overhead
Fetch class attribute can translate value0.00070.342110.0007
XML
Image XML parsing0.00030.131210.0003
General
dbfile0.01768.2488200.0009
String conversion0.00000.001330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs