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

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 18 2025 10:22:00
Script start
Timing: Jan 18 2025 10:22:00
Module start 'layout'
Timing: Jan 18 2025 10:22:00
Module start 'content'
Timing: Jan 18 2025 10:22:01
Module end 'content'
Timing: Jan 18 2025 10:22:01
Script end

Main resources:

Total runtime0.8321 sec
Peak memory usage4,096.0000 KB
Database Queries80

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 589.0391152.6250
Module start 'layout' 0.00760.0049 741.664139.4297
Module start 'content' 0.01250.8184 781.0938780.9766
Module end 'content' 0.83080.0012 1,562.070320.1875
Script end 0.8321  1,582.2578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4325160.0002
Check MTime0.00150.1800160.0001
Mysql Total
Database connection0.00070.089910.0007
Mysqli_queries0.729387.6415800.0091
Looping result0.00190.2329780.0000
Template Total0.787194.620.3936
Template load0.00200.245620.0010
Template processing0.785194.351020.3925
Template load and register function0.00020.020110.0002
states
state_id_array0.00120.148710.0012
state_identifier_array0.00520.621720.0026
Override
Cache load0.00200.24351290.0000
Sytem overhead
Fetch class attribute can translate value0.00090.103660.0001
Fetch class attribute name0.00220.2595130.0002
XML
Image XML parsing0.00260.316860.0004
class_abstraction
Instantiating content class attribute0.00000.0033130.0000
General
dbfile0.00130.1525420.0000
String conversion0.00000.001340.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
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
16content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 42
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs