Mapping multiple values to elements using CsvImport

Hi all,

I am trying to use CsvImport to map multiple values to elements in CsvImport. In my CSV file, it might say:

Name,Age,Friend,
John,27,"Jack, Gill, Robert",
Gill,26,"Jack, Matt"

Here, I would like the first Item record to have three separate Friend element/value pairs, and the second Item to have two.

What's currently happening is that I end up with a single Friend element containing the text "Jack, Gill, Robert" in the case of the first Item, for example.

I can map these values to separate Items tags easily enough, although this is not what I want.

Is what I am trying to do possible? And if so, is there something I am overlooking here?

Many thanks,

Dee

I think you will need to make different columns for each friend, so that it is Friend 1, Friend 2, Friend 3 -- to max # of friends in your database. Then, you can map friend 1, friend2, friend 3 to the appropriate metadata field. You will be able to have multiple inputs for each field.

Hi Sheila,

Apologies for the long break - I have come up against this problem again in a second Omeka project.

Your solution works well for the example above, but what if I had a variable number of Friends in each entry / CSV row (e.g. between 0 and 100). Then I would have to have 100 friend columns in my CSV just to be sure, but they will be sparsely filled - maybe only one guy has 100 friends and the rest have 2-3! Is that the only way to do this?

Thanks,

Dee

At present, that is the only way. It is a feature we are looking into for a new release of the plugin.

Yes, you have to prepare the file for the largest number of fields if all of your data is going into one CSV file and if you want each friend to be in is own field.

One idea is to create different CSV files, so that one contains the larger number of friend columns and then another CSV file that only has a few friend fields.