eZ Community » Forums » General » export csv ezpublish 4.2 ?

export csv ezpublish 4.2 ?

export csv ezpublish 4.2 ?

Monday 15 April 2013 10:04:25 am - 11 replies


I just pick a site under ezpublish 4.2 (yes I know ^ ^) and wanted to know how to export data in CSV format. I am greatly surprised that such functionality is not natively in a tool as powerful eZ Publish unless I'm squinting like a mole. In any case, can you please help me to do this? Thank you in advance to those who will look at these few lines.


Monday 15 April 2013 6:46:30 pm

The content model of eZ is very rich. You generally are better off exporting to XML than csv.

Apart from that, I´m sure the ezcsvexport script in bin/php can help you a lot. As well as a myriad "export" extensions available on projects.ez.no...

Tuesday 16 April 2013 4:48:07 pm


Thanks to you I grew ^^

Now I got this message : 

#################################### DEBUG ####################################

No timing points definedPeak memory usage: 6,188.5039 KBGroup ini_load:Load cache: 0.0042 sec (3.3880%), 0.0011 avg sec (4)FindInputFiles: 0.0014 sec (1.1463%), 0.0004 avg sec (4)Group Mysql Total:Mysqli_queries: 0.0218 sec (17.5525%), 0.0036 avg sec (6)Looping result: 0.0001 sec (0.1177%), 0.0000 avg sec (5)Group General:dbfile: 0.0003 sec (0.2377%), 0.0001 avg sec (5)
Total script time: 0.1242 sec

Can you help me ? Do you have any idea ?



Friday 19 April 2013 1:23:07 pm

What kind of data are you trying to export?

If you want to export all the data, I'd recommend a database dump.

Monday 22 April 2013 9:53:43 am


I just want to export a folder (from the backoffice) to a csv file.

The stored values ​​contain a lot of ez tags.



Monday 22 April 2013 1:07:18 pm

These are the commands I used to export users from eZ.

 cd ~/public_html/ez
 /usr/local/bin/php -C bin/php/ezcsvexport.php 12 –storage-dir=$CSV_EXPORT_BASE -ssite -q -l export -p password 2> /dev/null

You could use a template, it may seem odd, but it might be easier to code a template to deliver the content in .csv format than other approaches.

Also, although I've never tried it, you might want to look at WebDAV.

Or you can use custom PHP.

Modified on Monday 22 April 2013 1:08:36 pm by Betsy Gamrat

Tuesday 23 April 2013 11:42:41 am


Oh my god a csv file, empty file ok, but a csv file, thanks !

Can you explain me the different parameters (dynamic...) of this syntax or give me a referential site please ? Where did you learn that ?

php -C bin/php/ezcsvexport.php 12 –storage-dir=$CSV_EXPORT_BASE -ssite -q -l export -p password 2> /dev/null

Best regards,


Tuesday 23 April 2013 4:56:45 pm

Re Betsy, thanks a lot for your precious help. Gaetano too. 

If I add -c in the command I got this error :

PHP Deprecated:  Comments starting with '#' are deprecated in /applis/apache2/htdocs/site/ezcsvexport.php on line 1 in Unknown on line 0PHP:  syntax error, unexpected '(' in /applis/apache2/htdocs/site/ezcsvexport.php on line 11Could not open input file: 12

Without I got this message :  Failed to login with user mysql (database connexion)

Or : Going to export subtree from node 12 to directory /applis/apache2/htdocs/site/members.csv
Can not open output file for user class with my own ez ID.

Any idea ?



Wednesday 24 April 2013 10:03:25 am

1. you need to run the php script from the root directory of ezpublish. It's the correct way to make sure the autoload mechanism for php classes works

2. which version of php are you running?

3. the "-C" option is only useful for php-cgi, not for php-cli. Are you running php on the command line the "good" way?

4. just run ezcsvexport.php with the "--help" option to get a list of supported parameters with detailed description

5. try running the script without using extra options for db username or password, and instead of "-q" use "--logfiles" and "-d" to get more details

Friday 26 April 2013 5:54:24 am

I had to run the --help this to see what the options are, I've forgotten.

Using this: (community edition 2012.3), the options are:

12 –storage-dir=$CSV_EXPORT_BASE -ssite -q -l export -p password

12 is the node id

--storage-dir is the directory I stored the data in, I think it included some images and the .csv file

-ssite is the siteaccess, which may be unnecessary, however, this eZ installation was supporting two sites

-q is quiet, because it was run as part of a cron job and the output was actually filtered and piped out through mail

-l export was a user that had only the privilege to read the users (I'm not really sure, but that it a likely answer)

-p was the account password for export

 /usr/local/bin/php -C bin/php/ezcsvexport.php --help
Usage: bin/php/ezcsvexport.php [OPTION]... [NODE]
eZ Publish CSV export script

ezcsvexport.php --storage-dir=export 2

General options:
  -h,--help             display this help and exit
  -q,--quiet            do not give any output except when errors occur
  -s,--siteaccess       selected siteaccess for operations,
                          if not specified default siteaccess is used
  -d,--debug...         display debug output at end of execution,
                          the following debug items can be controlled: 
                          all, accumulator, include, timing, error, warning, debug, notice or strict.
  -c,--colors           display output using ANSI colors (default)
  --no-colors           do not use ANSI coloring
  -l,--login USER       login with USER and use it for all operations
  -p,--password PWD     use PWD as password for USER
  --logfiles            create log files
  --no-logfiles         do not create log files (default)
  -v,--verbose...       display more information, 
                          used multiple times will increase amount of information
  -r,--allow-root-user  Allows the script to be run by the root user

  --storage-dir=VALUE  directory to place exported files in


 /usr/local/bin/php -v
PHP 5.2.17 (cli) (built: Aug  2 2012 18:45:57) 
Copyright (c) 1997-2010 The PHP Group

To answer the question how did I learn this, I needed a way to export the users and I remembered seeing the script in the bin directory.  I used --help and adjusted the options until I was happy with the output.

Wednesday 15 May 2013 3:12:04 pm

Hi & thanks, I'm back with it.

It seems to be the good way because when I execute this :

php ezcsvexport.php 12 --debug=all -l admin -p publish --storage-dir=exported

I got an empty csv file called users.csv in the directory "exported"

I got too this following error :

Going to export subtree from node 12 to directory exported
PHP Fatal error:  Call to a member function attribute() on a non-object in /applis/apache2/htdocs/site/kernel/classes/datatypes/ezuser/ezusertype.php on line 377
Fatal error: eZ Publish did not finish its requestThe execution of eZ Publish was abruptly ended, the debug output is present below.No timing points definedPeak memory usage: 7,415.9609 KBGroup ini_load:Load cache: 0.0035 sec (2.5054%), 0.0005 avg sec (7)Group Mysql Total:Mysqli_queries: 0.0268 sec (19.3119%), 0.0021 avg sec (13)Looping result: 0.0003 sec (0.1808%), 0.0000 avg sec (11)Group General:dbfile: 0.0003 sec (0.1918%), 0.0001 avg sec (5)
Total script time: 0.1388 sec

WTF ? Any idea ?



Monday 03 June 2013 12:22:11 pm



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

36 542 Users on board!

Forums menu

Proudly Developed with from