Support multiple values per field
patchak - December 19, 2008 - 14:07
| Project: | CSV Parser |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hey there, I was wondeting how to format the data to have multiple values per field ?? Is it possible?
thanks
Patchak

#1
Hello,
I was thinking about the same.
For example, how to feed multiple taxonomy tags in there? As separate fields?
Also, how to map hierarchical taxonomy?
#2
Well I don't know how csv format handles multiple values anyway... is there a way with csv to have multiple values ?? Once we know how to format our data it would be easier to import... ??
Patchak
#3
This is supported in a rudimentary fashion in the alpha1 version (see title rules etc on the node edit form of a feed). Not supported in .dev version.
Important feature request.
#4
Useful feature.
I need something similar for importing multiple taxonomy terms.
One suggestion:
Have a different delimiter for 'multiple items within a single column'.
Eg my import csv file is comma separated.
Where I have a multi valued field, I separate the items with a different delimiter, eg ';'
So my import file looks like
Joe,Bloggs,red;green;blue,malewhere red green and blue are 3 values for the one field, whether it be taxonomy, cck text, whatever.
Alan
#5
I'm more thinking of a solution where
* you can map more than one column into a single node feature (title, taxonomy, etc.) with simple rules (concatenation, glue characters)
* you can group by a specific column. Differing entries in grouped rows become arrays that can be mapped to node features like taxonomy.
#6
Hey there, I'm very interested in this feature as I really need it for a new project. Was there any work done about this? I'm ready to sponsor this feature if anyone wants to take the time to set it up like alex_b suggested!!
Patchak
#7
@patchak: I am happy to provide guidance for such a patch. Unfortunately I can't work on it personally though.
#8
alex_b comment #5: how would either of these solutions work when there was an arbitrary number of values attached to a multi-value field? Surely you wouldn't have (say) 100 "columns" in the CSV for taxonomy terms for vocabulary A, and another 100 for terms for vocabulary B? (even though most of the time, this would be 0-10 values). Ditto for any other multi-value field?
Naively, it seems like having a separate delimiter for within the comma-seperated values might be the simplest idea?
#9
Actually not. Multi value fields are represented in tables better as multiple lines where all column values stay the same except the multiple. For example, think of how a relational database does this.
The way to retrieve these multiples is to tell the parser of the data to group by certain values. E. g. if you would have a table of nodes, you would tell the parser that it should group by nid. Every column that yields multiples would be treated as a field with multiple values.
#10
That's the second suggestion from #5? Would you expect multi-value columns to be on subsequent lines? (otherwise we have to keep track of too much, and/or load nodes). How would we define the "primary key" for these records?
#11
"Would you expect multi-value columns to be on subsequent lines?"
Yes
"How would we define the "primary key" for these records"
the user would have to specify a 'group by' field. For a node import, this would be e. g. a nid.
#12
"the user would have to specify a 'group by' field. For a node import, this would be e. g. a nid."
Allowing the user to specify a field to use as the primary id/group by field could also allow for updating rows where some of the column data has changed. In the current code (-dev) it looks like any changes in the row would result in a new guid.
parser_csv.inc:
<?php// Use hash of line for building a GUID.
$item->options->guid = hash('md5', serialize($row));
?>
#13
I just tried importing tags like this
"these,are,my,tags"
which ideally should be 4 different tags, yet they were imported as one tag with the commas.
#14
me too. Sample feed item shows
tag1, tag2 as expected
But the taxonomy field for the node is set to "tag1, tag2" (with the quotes) so it outputs it all as one long taxonomy term.
I'd expect it to set the taxonomy field to tag1, tag2 resulting in taxonomy terms of tag1 and tag2