Forums / Developer / Import CSV in EZP 3.9 : Missing doc

Import CSV in EZP 3.9 : Missing doc

Author Message

Kristof Coomans

Friday 09 February 2007 6:29:25 am

Hi Sébastien,

Include kernel/classes/ezcontentclass.php

a little bit off topic but maybe this one can be useful for you too: http://pubsvn.ez.no/community/trunk/extension/cddb. I'll upload the content classes I use this weekend.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Friday 09 February 2007 7:10:41 am

Hi Kristof ,

Thanks for your help, I have looked your module, but you don't include the library who contains the eZContentClass declaration. I think this is because you are into a module, but I'm not into a module (I execute my script by the shell).

I have included this files :

include_once( 'kernel/classes/ezcontentclass.php' );
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'kernel/classes/eznodeassignment.php' );

And running this :

$newAlbumId=ajouterAlbum($album1_name,$album1_year,true,64);
print_r($newAlbumId);

I get this error :

Array
(
    [result] => Array
        (
            [statut] => erreur
        )

    [msg] => node_id=64 doesn't seem to be a valid node id
)

But 64 is a valid node id, so I think that this instruction : $node =& eZContentObjectTreeNode::fetch($node_id);
is not executed properly, but I don't know why =(

eZ Publish Freelance
web : http://www.webaxis.fr

Kristof Coomans

Friday 09 February 2007 7:25:30 am

Hi Sébastien

It's better to write a real eZ command line script by using the eZScript class, so your eZ environment gets initialized properly. Take a look at the scripts in bin/php as an example. There are also some related code snippets on eZpedia: http://ezpedia.org/wiki/en/content/search?SearchText=script

Some other useful forum topics:
http://ez.no/community/forum/developer/php_script_problem
http://ez.no/community/forum/developer/launching_a_script

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Friday 09 February 2007 7:42:33 am

This links are very good !!

I think I can succes with this, thanks ;)

eZ Publish Freelance
web : http://www.webaxis.fr

Kristof Coomans

Friday 09 February 2007 7:48:36 am

Stub node on eZpedia: http://ezpedia.org/wiki/en/ez/command_line_scripts

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Friday 09 February 2007 8:00:43 am

dev evening in perspective !

eZ Publish Freelance
web : http://www.webaxis.fr

Daniele Nocentini

Wednesday 28 February 2007 12:54:43 am

Hello!
I try the ezcvsimport function with a simple class with only eztextline datatype, now I would like to try with date or date/time datatype, what is the right syntax in cvs file for this datatype?

Antica Bottega Digitale srl
http://www.abd.it

H-Works Agency

Thursday 08 March 2007 7:21:45 am

What is the correct syntax to import 'ezoption' datatype ?

Thanx

EZP is Great

Stefan de Bruijn

Sunday 15 July 2007 11:17:38 am

When trying to import data into a custom class, which contains an ezuser type, i get the following error:

# php bin/php/ezcsvimport.php -d -v --creator=14 --class=ow_persoon 203 teztuser.csv
Going to import objects of class ow_persoon under  node 203 from file teztuser.csv

Fatal error: Call to a member function on a non-object in /.../kernel/classes/datatypes/ezuser/ezusertype.php on line 393

With the modification from Rodrigo Pinheiro i got the same result, maybe because this only works for the standard 'user' class. With a mod of his mod, i can now import ezusers:

At line ' switch ( $datatypeString = $attribute->attribute( 'data_type_string' ) ) { '
Add the following case:


		case 'ezuser':
		// create array of userdata
		$csvUserData = explode( '|', $dataString );
	   	$userAccountObject = eZUser::fetch($attribute->ContentObjectID);
		
		// only first 2 items are used
		$username = $csvUserData[0];
               	$email = $csvUserData[1];
               	
               	// password is created by ez publish, not from csv
               	$password = eZUser::createPassword(6, 0);
               	$confirmPassword = $password;
               	$password_hash = md5( "$username\n$password" );
               	$userAccountObject->setInformation($contentObject->attribute('id' ), $username, $email, $password, $confirmPassword);
               	$userAccountObject->store();
               	// echo user and created password 
               	echo "user: " . $username . " password: " . $password;
               	break;

Kristof Coomans

Wednesday 18 July 2007 5:49:36 am

The error you get is probably related to this bug report: http://issues.ez.no/11092

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Daniele Nocentini

Monday 30 June 2008 9:01:08 am

When I try to import string that contain a special char such as "è à ì ò" frequent in italian's words, the import script truncate the string before the special char.

Antica Bottega Digitale srl
http://www.abd.it

H-Works Agency

Tuesday 01 July 2008 3:10:52 am

Hello,

I think this is a charset problem between your string and ezp.

You should try to make both compatible. Maybe using a utf8_encode(), or another charset conversion php function, before passing your string to the toString() import function.

EZP is Great

Daniele Nocentini

Tuesday 01 July 2008 3:31:08 am

I have modified the line 163 from:

$attribute->fromString( $dataString );

to:

$attribute->fromString( utf8_encode($dataString) );

now work fine and import also string with special chars.

Thanks.

Antica Bottega Digitale srl
http://www.abd.it

eZ debug

Timing: Jan 31 2025 01:14:07
Script start
Timing: Jan 31 2025 01:14:07
Module start 'content'
Timing: Jan 31 2025 01:14:07
Module end 'content'
Timing: Jan 31 2025 01:14:07
Script end

Main resources:

Total runtime0.3495 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0084 588.4766370.2891
Module start 'content' 0.00840.0163 958.76561,022.0547
Module end 'content' 0.02470.3248 1,980.82033,910.2109
Script end 0.3495  5,891.0313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00451.2761200.0002
Check MTime0.00140.4018200.0001
Mysql Total
Database connection0.00070.186310.0007
Mysqli_queries0.228765.44061410.0016
Looping result0.00160.45931390.0000
Template Total0.324392.810.3243
Template load0.00090.245110.0009
Template processing0.323492.530710.3234
Override
Cache load0.00060.169410.0006
Sytem overhead
Fetch class attribute can translate value0.00180.511010.0018
XML
Image XML parsing0.00020.060610.0002
General
dbfile0.02577.3560200.0013
String conversion0.00000.002330.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