This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » Importing data into ez

Importing data into ez

Importing data into ez

Thursday 03 April 2003 9:59:12 am - 7 replies

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


Thursday 03 April 2003 10: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.


Sunday 06 April 2003 12:37:52 pm

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).



Thursday 01 May 2003 12:28:28 pm

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!

Jørgen Skogstad

Wednesday 15 October 2003 2:56:32 pm

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:

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

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 );

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

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

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';
fclose( $handle );
echo "Done! " . time();
echo "Objects created: " . $counter;

Any ideas?


Thursday 16 October 2003 10:42:40 am

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

Monday 15 December 2003 1:56:15 pm

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


Friday 30 January 2004 4:21:16 pm


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!


Modified on Monday 02 February 2004 10:32:43 am by James Packham


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from