What is the separator for importing multi-value field using spreadsheets

33 views
Skip to first unread message

Robert Loo

unread,
Feb 28, 2023, 1:20:27 PM2/28/23
to TopBraid Suite Users
Hi, 

I want to import a spreadsheet with columns that have multi-value fields. What do I use as separator?

Thanks,
Robert

Holger Knublauch

unread,
Feb 28, 2023, 2:20:36 PM2/28/23
to topbrai...@googlegroups.com
What file format is your starting point? Could you paste a couple of example rows?

Holger


--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/1cc83a34-9467-4d62-8f1f-c2eb9795c3a5n%40googlegroups.com.

Robert Loo

unread,
Feb 28, 2023, 4:09:41 PM2/28/23
to TopBraid Suite Users
Attached is xlsx example for Hurricane as the prefLabel and typhoon and cyclone as the altLabels, using a semicolon as separator.

In a Taxonomy asset collection, I go into Import tab > Import Spreadsheet Using Pattern > No Hierarchy. 

Here is the preview triples:
example:Hurricane rdf:type skos:Concept ; rdfs:label "typhoon;cyclone" ; skos:prefLabel "Hurricane" .

I expect this instead:
example:Hurricane rdf:type skos:Concept ; rdfs:label "typhoon" ;
rdfs:label "cyclone" ; skos:prefLabel "Hurricane" .

I also tried pipe as separator but doesn't work. 

Thanks,
Robert

Robert Loo

unread,
Feb 28, 2023, 4:09:41 PM2/28/23
to TopBraid Suite Users
Here is the attachment.


On Tuesday, February 28, 2023 at 2:20:36 PM UTC-5 Holger Knublauch wrote:
import_example.xlsx

Holger Knublauch

unread,
Mar 1, 2023, 5:10:27 AM3/1/23
to topbrai...@googlegroups.com
Hi Robert,

thanks for the example file. I don't believe we have built-in support for mapping individual cells to multiple values from the interactive spreadsheet importer.

I see two options to proceed:

1) Post-process the values after import, e.g. use the Script Editor (in unlocked mode as shown)

PastedGraphic-1.png

Here would be that script for copy-and-paste

skos.everyConcept().forEach(concept => {
let old = concept.altLabel;
if(old.length == 1 && old[0].indexOf(';') > 0) {
concept.altLabel = old[0].split(';');
}
});

2) Don't use the spreadsheet importer at all and use a script-based importer from the start. This is explained at

Here is an example script that should work (although you first need to re-save the Excel as TSV or CSV)

PastedGraphic-2.png

Example Preview:

PastedGraphic-3.png

For copy and paste:

let s = IO.uploadedFile(file).asSpreadsheetIterator();
for(let row of s) {
let c = skos.createConcept({
uri: 'http://example.org/concept/' + encodeURIComponent(row.prefLabel),
prefLabel: row.prefLabel,
altLabel: row.altLabel.split(';')
});
}

In general, the Script-based importers offer much greater flexibility, but you'd need someone in the team who understands JavaScript to produce these scripts.

Scripts can be wrapped into Modify actions so that anyone can use them easily:


HTH
Holger



Reply all
Reply to author
Forward
0 new messages