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
|