CSV Import - set language for uri

Hi all,

I believe the CSV Import module doesn’t (yet) take into account the language settings for datatype uri. Is this correct? I’ve tried it but, the columns get imported without the @language.

Here are the (test) settings I’ve used:
{
“filename”: “mediumplay.csv”,
“filesize”: “7417”,
“filepath”: “/tmp/omekakhtzS1”,
“media_type”: “text/csv”,
“resource_type”: “items”,
“comment”: “”,
“automap_check_names_alone”: true,
“column-data-type”: [
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“literal”,
“uri”,
“uri”
],
“column-property”: {
“4”: {
“dcterms:publisher”: 5
},
“11”: {
“dcterms:extent”: 25
},
“12”: {
“dcterms:provenance”: 51
},
“13”: {
“dcterms:spatial”: 40
},
“15”: {
“dcterms:medium”: 26
},
“16”: {
“dcterms:medium”: 26
}
},
“column-language”: {
“15”: “nl”,
“16”: “en”
},
“generic-data”: “default”,
“media-source”: “default”,
“o:resource_template”: “”,
“o:resource_class”: “”,
“o:owner”: {
“o:id”: 1
},
“o:is_public”: 1,
“o:site”: [
“1”
],
“multivalue_separator”: “,”,
“global_language”: “nl”,
“action”: “create”,
“identifier_column”: 0,
“identifier_property”: “”,
“action_unidentified”: “skip”,
“rows_by_batch”: 20,
“column-multivalue”: [],
“delimiter”: “,”,
“enclosure”: “"”,
“escape”: “\”
}

Any workarounds?

Thanks,
T

I’ve tinkered a little with the PropertyMapping.php and added a few lines to this snippet:


             foreach ($propertyMap[$index] as $propertyTerm => $propertyId) {
                    foreach ($values as $value) {
                        $valueData = [];
                        switch ($typeAdapter) {
                            case 'uri':
                                // Check if a label is provided after the url.
                                // Note: A url has no space, but a uri may have.
                                if (strpos($value, ' ')) {
                                    list($valueId, $valueLabel) = explode(' ', $value, 2);
                                    $valueLabel = trim($valueLabel);
                                } else {
                                    $valueId = $value;
                                    $valueLabel = null;
                                }
                                $valueData = [
                                    '@id' => $valueId,
                                    'property_id' => $propertyId,
                                    'type' => $type,
                                    'o:label' => $valueLabel,
                                ];
                                if ($globalLanguage !== '') {
                                    $valueData['o:lang'] = $globalLanguage;
                                }
                                if (isset($languageMap[$index])) {
                                    $valueData['o:lang'] = $languageMap[$index];
                                }
                                break;

This seems to work !

You’re correct that CSV Import currently only honors the language settings for “literal” values, not URIs.

We’ll change that so it does support language for URI values as well.

1 Like

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.