Forums / Setup & design / Exporting data (CSV)

Exporting data (CSV)

Author Message

laurent le cadet

Friday 08 July 2005 6:50:04 am

Hi,

Is there a simple way to export data ?
I need to create a text file with all the items of a specific classe and retrieve all attributes line by line.

Possible ?

Regards.

Laurent.

Steve P

Saturday 09 July 2005 2:34:03 am

I've just installed a fantastic extension:
http://ez.no/community/contribs/import_export/csv_extract_pubsvn

It was a doddle to install & I think can be easily adapted to suit your requirements.

Best

Steve

laurent le cadet

Saturday 09 July 2005 3:28:24 am

Hi and thanks for response,

I'm trying to install the extension I'm not very familiar with extensions.

I tryed to place the files in the right place but not sure it's the right way

What I've done :

extension/extract/modules/extract

- module.php
- user.php

extension/extract/packages

- empty folder (what is use for ?)

extension/extract/settings

- module.ini.append

settings/override/site.ini.append.php

[ExtensionSettings]
ActiveAccessExtensions[]=extract

ModuleList[]
ModuleList[]=extract


Part[ezextractnavigationpart]=Extract


[TopAdminMenu]
Tabs[]=extract
[Topmenu_extract]
NavigationPartIdentifier=ezextractnavigationpart
Name=Extract
Tooltip=Extract Users to csv
URL[]
URL[default]=extract/user
Enabled[]
Enabled[default]=true
Enabled[browse]=false
Enabled[edit]=false
Shown[]
Shown[default]=true
Shown[edit]=true
Shown[navigation]=true
Shown[browse]=false

settings/override/

- browse.ini.append.php

settings/override/

- design.ini.append.php

settings/override/

- export.ini.append.php (write [ExportSettings] instead of [ExportSettngs] )

standard/templates/extract

- browse_node.tpl
- user.tpl

-----end

I think I forgot something or maybe there is a fine tune to perform cause by clicking on the tab "Extract" ezP can't findthe module...

Laurent

Marco Zinn

Saturday 09 July 2005 3:31:28 am

As Björn created some extension for this, use it :)

I think, you should be able to do this with pure templating, too, but this will be some work.

Marco
http://www.hyperroad-design.com

laurent le cadet

Saturday 09 July 2005 3:38:45 am

Hi marco,

I'm almost trying to use it !

What you mean by "use it" ?
Isn't it the right way to install it ?

Laurent

Steve P

Saturday 09 July 2005 3:49:46 am

Hi Laurent

I think you're trying to make it too complicated! Just unpack the files & copy to your extensions dir. Add the lines:

[ExtensionSettings]
ActiveExtensions[]=extract

[ModuleSettings]
ExtensionRepositories[]=extract

..to your settings/override/site.ini.append, clear the caches & bingo!!

laurent le cadet

Saturday 09 July 2005 4:13:23 am

As you said : BINGO !

I just add in override/menu.ini.append.php

[TopAdminMenu]
Tabs[]
Tabs[]=extract

because there was no "Extract" tab.

Nice job (not mine ;)

Many thanks to Björn and both of you !

Laurent.

Steve P

Saturday 09 July 2005 4:24:09 am

I didn't need the menu mods?

Glad it's running OK :)

Do you know anything about the store() function? See my post...

laurent le cadet

Saturday 09 July 2005 4:24:53 am

Sorry to be back again.

I just wanted to say it was REALLY a nice job and exactly what I was looking for !

Steve P

Saturday 09 July 2005 4:26:20 am

Me too! I'd been struggling to try & implement something much simpler...

laurent le cadet

Saturday 09 July 2005 4:29:31 am

Sorry Steve I don't think I'll be helpfull about the store() function

Pål J Didriksen

Saturday 09 July 2005 5:32:37 am

I also installed the extension. But my date-fields are shown as "Object" in the CSV-file.

Any tips on how to turn it into a proper date?

Steve P

Monday 11 July 2005 2:01:16 am

Pål. Assume you'll need to modify the templates but maybe the developer Björn Dieding ( bjoern@xrow.de ) would be interested in looking at this one?

Let me know how you get on...

laurent le cadet

Monday 11 July 2005 2:10:12 am

Pål,

I have also the same result for specific datatypes but most of them are supported.

Let us know if you find the way to extend to all datatypes.

Laurent

Paul Borgermans

Monday 11 July 2005 2:26:29 am

Yes,

The function

function parseContentToText( &$datatype )

in the file modules/extract/user.php

needs to be extended for some of the datatypes (maybe also custom datatypes)

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Pål J Didriksen

Monday 11 July 2005 3:54:16 am

I added some code to treat the 'ezdate' datatype, under <i>function parseContentToText( &$datatype )</i>:

           case 'ezdate':
                print "parseContentToText 5: Case ezdate.<br>";
                $content = $datatype->title();
            break;

I suppose this should work for most datatypes (except those that save data as xml), as the function <i>title()</i> formats the data that should be saved in the data_text-field. I have only tested it for ezdate, though.

Steve P

Tuesday 12 July 2005 6:36:22 am

Pål

Can you post your mod in context please? I managed to crash it so must have got it wrong :(

           case 'ezdate':
                print "parseContentToText 5: Case ezdate.<br>";
                $content = $datatype->title();
            break;

Pål J Didriksen

Tuesday 19 July 2005 11:18:32 am

In my version of extract/modules/extract/user.php, the function parseContentToText now looks like this:

function parseContentToText( &$datatype )
{
    if ( is_object( $datatype ) )
    {
        $isA = $datatype->isA();
        switch ( $isA )
        {
            case 'ezselection':
                $content = $datatype->content();
                if ( is_array( $content ) and count($content) == 1 )
                {
                    $content = $datatype->metaData();
                }
                else
                {
                    $content = $datatype->isA();
                }
                break;
            case 'ezdate':
                $content = $datatype->title();
                break;
            default:
                $content = $datatype->content();
                break;
        }
    }
    else
    {
        $content = $datatype;
    }
    return $content;
}

laurent le cadet

Monday 05 March 2007 11:46:31 pm

Hi,
About ezselection datatype...I'm trying to extract datas with a multioptions selection but I don't know how.

Someone can help me to render it lke that :

column header : option name
raw content : is selected or not

Any idea ?

Regards.

Laurent