Import data to custom fields

Is there an easy way to upload a CSV file with items to insert into a custom field?

Comments

  • Hi Andy,

    Yep, Data Admin can import CSV data into custom fields, and it handles merging them into any existing serialized data. Here's a previous post with the info for how to set it up. Easy is relative, but in theory you just need to create the YML file with the names of the fields as a Custom Import:

    https://ask.gibbonedu.org/discussion/comment/3920#Comment_3920

    Hope this helps!
    admin
  • Thanks Sandra. Will give it a go.
  • edited September 2018
    I gave it a go. Got to the dry run successfully but when I submitted I got error messages:

    Warning: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `gibbonPersonID`='0000001413'' at line 1 in /home/rapid1/public_html/purongo/anfield/src/Gibbon/sqlConnection.php on line 171

    The first few lines of the csv file are:
    PersonremarkCustom Fields
    20130101 "words words words"

    20130106
    20130107
    20130114 "words words words"


    Any thoughts as to what I need to do? I've tried replacing apostrophes with ` but same result.
    My custom field is 'remark'. What should go in the 'custom fields' column'?
  • edited September 2018
    Hi Andy,

    Hmm, odd. Is the whole CSV file quoted with "", or just the one remarks field? The extra ""s might be throwing off the importer. When assigning the columns in step 2 (right before the Dry Run) did the column of preview data appear correct?

    The Custom Fields column can be set to [Custom Value] and then left blank. The actual value & serialization is handled by the importer (but it does need to be there, for reasons I don't currently recall).


    If need be, there's some debug output on lines 560-562 of /modules/Data Admin/src/Importer.php you could enable to see where the malformed part of the SQL is.

    Also, I've edited your post to remove what might have been personal details.
  • The remark field is quoted but nothing else.
    I have removed all quotation marks from the text to be sure.
    Preview and dry run look fine.
    I'll take a look at the debug.
Sign In or Register to comment.