Search

Haven't tested it yet, so I'm not sure...

Hi there, I need a hint. How it possible to export/import meta keys field. Maybe someone knows what can be done about that?

At the moment, this is not possible. The question on how to achieve this also depends on some factors. Meta keys are multiple key->values for one field-type. In CSV this should be noted as one cell. This is tricky. You could serialize it in case of a meta-keys-field but then it would be human-unreadable in the CSV-format.

If you don't want it to be human-readable (just import it from site A to site B for example) this could work, but if you want your client to provide the assets in a Excel-format for example (where each row stands for one entry) this is unusable.

Another option would be to have some sort of string formatting to handle te import correctly. Something like ['key'>>'value', 'key'>>'value', 'key'>>'value'] for example, but you would have to keep in mind that this could cause some issues when the content has characters like ' or > for example.

I have a fatal error:

Symphony Fatal Database Error
Table 'symphony_openbook.sym_entries_data_' doesn't exist

An error occurred while attempting to execute the following query

    DELETE FROM sym_entries_data_ WHERE `entry_id` = '998'

Backtrace:

    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/symphony/lib/toolkit/class.mysql.php:458] MySQL->__error();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/symphony/lib/toolkit/class.mysql.php:586] MySQL->query();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/symphony/lib/toolkit/class.entrymanager.php:149] MySQL->delete();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/symphony/lib/toolkit/class.entry.php:295] EntryManager->add();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/extensions/importcsv/content/content.index.php:272] Entry->commit();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/extensions/importcsv/content/content.index.php:37] contentExtensionImportcsvIndex->__importStep3Page();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/symphony/lib/toolkit/class.administrationpage.php:260] contentExtensionImportcsvIndex->view();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/extensions/importcsv/content/content.index.php:25] AdministrationPage->build();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/symphony/lib/core/class.administration.php:222] contentExtensionImportcsvIndex->build();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/symphony/lib/core/class.administration.php:375] Administration->__buildPage();
    [/Users/johnporter/Projects/Websites/Open Book Publishers/assets.openbookpublishers.com/httpdocs/index.php:25] Administration->display();

Don't know what caused this, I'll have a look into my CSV to see if was that.

Import/export CSV updated to version 0.1.4 on 30th of May 2011

Added support for selectbox link field

Giel,thanks for your valuable extension. It works almost perfectly. Just few notes if u don't mind )). It would be nice to have option to choose the delimiter on first stage of csv import. The option 'auto' in parsecsv.php doesn't work for me ('cos i have to use tab delimiter and it didn't understand that due to numerous commas in fields). Finally, i still didn't understand how to populate the 'select box link' fields with values. E.g. i have 'cities' in my csv. So importing 'London, Moscow, Dayton', etc produces nothing but 'none' :-(

@timeteka: have you tried London,Moscow,Dayton as well (note there is no space after the comma)?

I'll look into the delimiter stuff. I had this option in it in an earlier version, but omitted it in favor of the auto-detect functionality.

Don't understand you. What's the difference whether i have spaces in csv or not? i just enumerated the values for example. i have London in the 1st field, Moscow in 2nd and Dayton in the last field of my csv file. :-)

I just wanted to say, that i'd like to automatically enter new values into the select box links (corresponding sections). Seems your extension can't do that so far. It's also cool to preserve 'unique'-ness of the data entered.

As for the delimiter stuff, it would be nice to have a textfield on the 1st stage to manually set the delimiter before import.

Finally, i still didn't understand how to populate the 'select box link' fields with values. E.g. i have 'cities' in my csv. So importing 'London, Moscow, Dayton', etc produces nothing but 'none'

Select Box Link values are numeric (entry IDs), so you need to pass those in your import CSV.

@Lewis: No, the importer automagicly chooses the correct ID for the value. This is because when a client imports or exports assets, ID's aren't human-readable.

@Timteka: With multiple values these need to be stored in one cell. So the value in your CSV file should look like "Moscow,Dayton" instead of "Moscow","Dayton".

Giel, Mark, you still can't understand me :-)))) Ok, once again. I have a csv On the symphony side i have section populated with cities called Cities. Another section is Shops with fields title (textfield), address (textarea), city (select link box -> from Cities). The partner sends me an xls with the following data:

Shop1 [tab] Address1 [tab] London
Shop2 [tab] Address2 [tab] Moscow
Shop3 [tab] Address3 [tab] Madrid

where [tab] - is just a separator :-) So what i wish is to have cities inserted into the Cities section. With uniqueness or without it (if former is difficult to achieve). I can't ask the partner to insert any ID's instead of cities names.

@timteka: you don't have to use ID's, because the extension automaticly looks for the right ID according to the value. So if your city-entry for London has ID=10, then it looks for value London and gets the correct ID. But: the data should match exactly. So if your City is noted as London(space) or (space)London (note the extra space) or the data in your CSV is london, or londen. (note the case-change and the typo), then it will fail. I'm not sure but maybe an EOL could also cause the problem. Have you tried wrapping your values in your CSV files with quotes? Like:

"Shop1","Adress1","London"
"Shop2","Adress2","Moscow"
"Shop3","Adress3","Madrid"

From what I can see in the Import/Export CSV code it doesn't do a lookup to get the ID given a value for a Select Box Link, it just expects ID's when importing.

There is some code to get the correct Value given an ID for exporting, but I can't see where this occurs in importing, and I'm unsure how you'd even do it.

The Select Box Link field expects ID's for the processRawFieldData function, not values or handles. The buildDSRetrivalSQL functions accepts either ID's or values, so perhaps that could be used to take "London", "Moscow" and "Madrid" and return the ID's to pass to the processRawFieldData function.

Brendan, thanks for the reply. You are right. I understand only the logic, but lack knowledge of php scripting :-(. Giel, it would be cool to have empty (or not) section Cities and to be able to populate it with new values from CSV Importer. At least for me it seems obvious and makes your extension really tough. Suppose my request is common. Most of the users of csv importer won't be able to prepopulate the selectbox link section, having hundreds of items in csv. or am i wrong? :-)

Hm, by the way, import into select box link (where the correspondent section is prepopulated with values) still doesn't take place in my case. Encoding utf-8, no spaces in columns ... Still cruel word 'none' instead of field's value. So i've started investigation. Tracing the line with

$relatedids['relationid'][] = Symphony::Database()->fetchVar('entry_id', 0, 'SELECT entry_id FROM sym_entries_data_' . $related_field . ' WHERE value = '' . $value . '';');

showed that smth wrong with the $value, 'cos in log it prints out:

$value=
My city

What does it mean? Who enters the newline character? :-(

Poor newbie am i. The problem was with line endings. The php class used could correctly parse my csv. Added the following lines to parseCSV.php into 'loaddata' function: $data = strreplace( "rn", "n", $data ); $data = str_replace( "r", "n", $data );

Now import finishes as expected. Thanks for this extension, dear author ))

P.S. BTW, how about http://php.net/manual/en/function.fgetcsv.php/ ?

I don't know if I'm getting this right, but can you try replacing the explode(",", $value) function on line 220 of content.index.php to

preg_split("/[s,\"]+/", $value);

and see if that makes a difference... If you can test it for me first by placing

var_dump($data);die;

between lines 220 and 221 and post the results on here in a code block to see what the values are... Cheers.

Edit: You beat me to it, but still, Geil, if you do this switch, I reckon it is better than just splitting by ,, what do you think?

Import/export CSV updated to version 0.2 on 1st of June 2011

Improvements:

  • Import- and export-functions are now handled by seperate drivers, providing more flexibility for different types of fields. Read the documentation for more information on these drivers
  • Importing is now done with AJAX-calls, solving memory- and loadtime issues when trying to import, say, 2000+ entries. It also provides realtime importing-information, like elapsed time and estimated time left.
  • Added support for Subsection Manager, Status Field, Frontend Member Manager Password field.

Make this extension better!

Did you write a driver for a field? Share it with us! It will only make this extension better and stronger! Also you could help by testing and squashing bugs.

Hey Giel, the GIt repo zip and tar downloads don't seem to be working for me on the master branch.. so you know. I get a error page not found for the files.

Hey Giel, Can this extension handle importing into a section that already has data? and not overwrite but update the current data? or is this outside of the scope of what it's supposed to do and I should just look at events for this kind thing?

EDIT Sorry my bad.. Use the extension an the fruits will be yours eh! :)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details