Forums / Developer / Importing data into ez

Importing data into ez

Author Message

Claus Jensen

Wednesday 02 April 2003 11:59:12 pm

Hello,
is it possible to import data into content classes, and how do you do it if yes.

claÜs

Bård Farstad

Thursday 03 April 2003 12:06:52 am

Import of content classes and objects is not implemented in eZ publish at this time. So, to do imports you will need to write a script which does the job.

General imports are planned in future releases.

--bård

Documentation: http://ez.no/doc

Xavier Dutoit

Sunday 06 April 2003 3:37:52 am

Dear Bard,

I guess you've written some scripts to migrate the users from the previous ez site (2.x) to this new one (much bettter IMHO).

Would it be possible to publish these scripts as examples ?

Another point: how can you with the new interface reply to a reply post (eg. I wanted to reply to Bard post, but I could only do it with Claüs's one).

Thanks,

Xavier

http://www.sydesy.com

Jørgen Skogstad

Thursday 01 May 2003 3:28:28 am

Hi ..

Have you guys managed to write decent import scripts for Ez v3 yet? Would love to have some examples .. and see if I can contribute something. This is another area which is really important!

Kindest,
Jørgen Skogstad

Claus Jensen

Wednesday 15 October 2003 5:56:32 am

Hi again,
Im currently able to import a CSV file into ez-objects. The problem is that the whole file isnt imported. It runs to 249 or 250 objects every time, and then it stops...without any error. Does anybody have any ideas?? The script is based this:http://ez.no/developer/ez_publish_3/forum/developer/creating_a_simple_content_object_via_php

Here is part of the script. I didnt include the function createMetaObj(), since its working. I think the problem is elsewhere...

<?php
echo "Starting..." . time();
set_time_limit( 2500 ); //2500 sekunder, ca 41 minutter
//print( "Starting metadata import\n" );
include_once( "lib/ezutils/classes/ezdebug.php" );
//eZDebug::setHandleType( EZ_HANDLE_FROM_PHP );
include_once( "lib/ezutils/classes/ezmodule.php" );
eZModule::setGlobalPathList( array( "kernel" ) );
include_once( 'lib/ezutils/classes/ezexecution.php' );
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
eZDebug::setHandleType( EZ_HANDLE_TO_PHP );
eZDebug::setLogFileEnabled( false );
eZINI::setIsCacheEnabled( false );
function eZDBCleanup()
{
if ( class_exists( 'ezdb' )
and eZDB::hasInstance() )
{
$db =& eZDB::instance();
$db->setIsSQLOutputEnabled( false );
}
// session_write_close();
}
function eZFatalError()
{
eZDebug::setHandleType( EZ_HANDLE_NONE );
print( "Fatal error: eZ publish did not finish it's request\n" );
+
print( "The execution of eZ publish was abruptly ended." );
}
eZExecution::addCleanupHandler( 'eZDBCleanup' );
eZExecution::addFatalErrorHandler( 'eZFatalError' );
$db =& eZDB::instance();
$db->setIsSQLOutputEnabled( false );

//KLASSEID
$contentClassId = 28;
$userID = 15; //AUTHOR

//INPUTFILA
$handle = fopen ('importdata/WMO-Europe-stations_opencsv.xls', 'r');
//$handle = fopen ('importdata/stations_test', 'r');
//READING FILE
$counter = 0;
while ( !feof( $handle ) )
{
//$line = fgets( $handle, 4096 );
$line = fgets( $handle, 8192 );
//$columns = explode( ';', $line );
//SPLITTER PAA Tab
$columns = explode("\\t",preg_replace("/\t/","\\t",$line));

//REMOVING ALL "" FROM START AND END
foreach ($columns as $key => $val)
{
$val = rtrim($val, '"');
$val = ltrim($val, '"');
$columns[$key] = $val;
//print 'VERDI: ' . $val . ' ';
}

// Check that the line contains enough elements
//$columnCount = count( $columns );
// Get klubb
$strTitle = $columns[5] . ' - ' . $columns[7];
createMetaObj( $strTitle, $columns, $contentClassId, $userID );
//print '\n\n';
$counter++;
flush();
}
fclose( $handle );
eZExecution::cleanup();
eZExecution::setCleanExit();
echo "Done! " . time();
echo "Objects created: " . $counter;

Any ideas?

regards,
claÜs

Jan Borsodi

Thursday 16 October 2003 1:42:40 am

Do you know where it stops (which line/functioncall)?

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Claus Jensen

Monday 15 December 2003 4:56:15 am

Hi,
Sorry for answering late. Nope it gives no error or anything. Quite strange still.

regards,
claÜs

James Packham

Friday 30 January 2004 7:21:16 am

Hi,

I have a legacy system based on a Third party product called ArticleManager (some reference has been made to this in the forums before, I know), from which I need to output all the data for my new EZ Publish based website.

At the moment I've been staring at code and reading various documentation and forum posts for a few hours. I've also been toying with a bash script that basically extracts all the data to a text file and then to a csv (I have a number of these, one for each object class, each containing upto about 100 records). Since I'm a bit new to php and I'm still not sure what I'm doing, I was wondering if someone could explain a few parts of the Claus's script to me - so that I know what I have to change for my needs.

Looking at sections of Claus's code I think these are the bits I have to customise:

$contentClassId = 28;
$userID = 15;
$handle = fopen ('importdata/WMO-Europe-stations_opencsv.xls', 'r');
$columns = explode("\\t",preg_replace("/\t/","\\t",$line));

I just wanted to know:

a) am I right - is there anything else I need to change?

b) How do I define the delimiter for my csv file (which is like so "text","more text","....)?

c) How do I run the script (I assume it's just something like "php script.php" from the ez publish root directory)?

d) I've looked in the suggested places and I can't find the createMetaObj function, could anyone point me in the right direction?

Thanks in advance!

James

eZ debug

Timing: Jan 30 2025 00:46:14
Script start
Timing: Jan 30 2025 00:46:14
Module start 'content'
Timing: Jan 30 2025 00:46:14
Module end 'content'
Timing: Jan 30 2025 00:46:15
Script end

Main resources:

Total runtime0.1607 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.0060 587.9063180.8438
Module start 'content' 0.00610.0055 768.7500105.8359
Module end 'content' 0.01150.1491 874.5859533.8750
Script end 0.1606  1,408.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00322.0165200.0002
Check MTime0.00130.8223200.0001
Mysql Total
Database connection0.00090.583110.0009
Mysqli_queries0.117372.97751410.0008
Looping result0.00110.66971390.0000
Template Total0.148692.510.1486
Template load0.00080.496610.0008
Template processing0.147891.981410.1478
Override
Cache load0.00060.352210.0006
Sytem overhead
Fetch class attribute can translate value0.00100.624210.0010
XML
Image XML parsing0.00020.146310.0002
General
dbfile0.00694.3062200.0003
String conversion0.00000.003130.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.0001 secs