2

I have users each with a profile using the profile2 module. I am using a cookbook based on the Migrate framework to create the users and import profile data.

Sample CSV data would be:

"member_nr","email","username","tel_1"
"1001","new.tester@example.com","new tester","00000 12345-213"

But one of the profile fields is a text list using the checkboxes / radio buttons widget. According to the GUI, the values are stored in the format key|label.

So the field has values:

soccer|soccer
weight lifting|weight lifting
boxing|boxing
tennis|tennis
cooking|cooking

So I am trying to import data similar to:

"member_nr","email","username","tel_1", "interests"
"1001","new.tester@example.com","new tester","00000 12345-213", "soccer, weight lifting, boxing, tennis, cooking"

However, when running the import, I get an error that says:

SQLSTATE[22001]:String data, right truncated: 1406 data too long for column field_interests' at row 1: INSERT INTO... [the data from the CSV file]

How should multi values be formatted in the CSV file to be accepted?

  • I don't know, but commas don't work even when you don't get that error. – tog22 May 4 '14 at 1:31
0

Make sure you're mapping the field using the right separator, e.g.

$this->addFieldMapping('field_interests', 'interests')
     ->separator(',');

Then make sure you've the right length in the source field ($this->map) and your Drupal field support such lengths as well.

If this does not help, increase the length of the destination field by SQL, drush or hook_update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.