Hi ... I am having a problem with the mapping of Comma separated Taxonomy Terms.

My Example CSV File is attached. I mapped the Field Content "Gewinne" to a new created Vocabulary with Free Tagging and More select... ( Don`t know the Phrase in English )

But when there are more than one term in "Gewinne" i.e. "Bekleidung, Gutscheine, Schmuck" there ist only one new Taxonomy Term with the Name "Bekleidung, Gutscheine, Schmuck" created ... not three Single ones, as I would prefer.

If there is only one Term in "Gewinne" i.e. "Bargeld" everything is working fine ...

I tried different Delimiters, changed the CSV File ... But I don`t find a solution ... Can anybody give me a hand for this Problem?

CommentFileSizeAuthor
#1 example.txt394 bytesThoor
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Thoor’s picture

FileSize
394 bytes

an .csv File coundn`t be attached ... so there is a .txt Example for my CSV File

alex_b’s picture

Status: Active » Fixed

As you're not operating on any standard here, I recommend working with a custom parser that splits out cells by a custom delimiter (in your case it's a comma).

I just did this for one of our projects: http://gist.github.com/658222

Thoor’s picture

Hallo Alex,

The in my case used CSV Feed changed already, it is created with the VIEWS BONUS PACK ( So why is it not Standard? ) ... The URL to find the actual Feed is: http://www.gewinnspiele.be/gewinnspielfeed/csv

This Feed works great with FEEDS BETA09 and BETA08, where everything can be parsed and mapped. But not with BETA10, where you included http://drupal.org/cvs?commit=443308 Because there the Taxonomy Tags in "Preise" are not splitted, as they should be.

This is, what I can tell you so far ...

But THX anyhow Thomas

Sinovchi’s picture

Hi Alex,

I had the same problem with beta10. The 6.x-1.0-beta9 recognized the taxonomy tags field as in example field "Gewinne"

Content of this filed "Computer, Handy, Unterhaltungselektronik". After importing beta9 created 3 taxonomies, but beta10 only one "Computer Handy Unterhaltungselektronik" without comma

Is it a bug in beta10?

Thoor’s picture

As because the thread is marked as "fixed" ... start a new one with this issue ? Because of the posting from BIARR it seems not to be a personell problem for me?

alex_b’s picture

The behavior before http://drupal.org/cvs?commit=443308 was clearly a bug (comma separation of tags is really just a Drupal convention for the web UI). We can't go back on this fix as otherwise cells with commas can't be mapped to taxonomy terms (there is no way of escaping a comma for this purpose). Again, if you need to make cells in CSV files multi value the easiest solution is something like http://gist.github.com/658222

Sorry...

Thoor’s picture

Hi again Alex ...

You wrote: "as otherwise cells with commas can't be mapped to taxonomy terms (there is no way of escaping a comma for this purpose)."

This is my problem? I am having a comma separated cell with commas which I want to map to a taxonomy! Did you have a look on the new feed under: http://www.gewinnspiele.be/gewinnspielfeed/csv

The cell "Preise" contains often more than one Taxonomy Term, separated by commas. But only BETA9 does separate the terms by importing...

i.e. Row 5 - GUID 4668 ... the Cell "Preise" contains "Bekleidung, Gutscheine, Schmuck"

the BETA9 does create the single Taxonomy Terms "Bekleidung", "Gutscheine", "Schmuck"
the BETA10 does create only one Term ""Bekleidung Gutscheine Schmuck"

I don´t understand why i should change the output of the cell? This is a regular cell output - or not?

If it is really necessary ... i don´t understand, what to do with your recommend under http://gist.github.com/658222
Where should this be used? Is it some code for the VIEW Template File? Or a mini module?

Thank you for your patience with my problem!
Thomas

alex_b’s picture

Or a mini module?

Exactly =)

Thoor’s picture

Exactly =)

Uahhhh .. this answer i was afraid of! :-) Never did this before - wish Good Luck to me ...

THX Thomas

PS: I still don´t get the reason why this is necessary ... so my last question to this: Could I avoid the mini-Module, when I change the output of my CSV File, especially the comma separated terms?

So could you tell me, what the Items should be separated in the csv-file to work with FEEDS Beta10 out of the box? This is maybe easier, than work on a very first module ...

podox’s picture

I would agree that, in the majority of circumstances, by importing commas into a taxonomy field you would want the commas to act as separators for the taxonomy terms. It seems more practical, as taxonomy fields are mainly used for lists of terms rather than sentences which may inadvertently contain commas. For the latter I would tend to import it into a CCK text field.

I'm sure there are situations where #6 makes sense, but I think they're less common than the use case mentioned above.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

videographics’s picture

Category: support » feature
Status: Closed (fixed) » Active

In post #6 alex_b says, "if you need to make cells in CSV files multi value". Aren't virtually all taxonomy imports going to include multiple values? I think this is so standard that I understand Thoor's reaction. Feeds should definitely have a "standard" way of importing multiple taxonomy terms. Obviously, there SHOULD be an interface to choose a delimiter for fields with multiple values just like there's an option to choose a delimiter for fields. Why can't you separate your records with tabs and use commas for the fields?

If the code doesn't even do the thing Thoor innocently ask for help with, it should be a feature request. It was SO obvious to him that this should work, he just assumed it was a feature.

(Should this be a feature request or a bug report? Turning a list of taxonomy entries into one big string of words is pretty useless and can cause some major trouble for users who might start down this road expecting this to work.)

yurtboy’s picture

did anything come of this?

podox’s picture

Feeds Tamper allows you to choose a delimiter for Taxonomy terms. It worked well when I tested it with an RSS feed although there were apparently problems with CSV files - see #992420: Can't get explode to work with CSV parser

yurtboy’s picture

this has been working for me after importing a 1000 or so nodes.
http://drupal.org/node/1039134

cedarm’s picture

Just updated #925264: Don't allow commas in tag names to allow commas in terms. As long as the Parser (or Feeds Tamper) supplies an array of terms to the processor/mapper everything should just work. But that's the trick - get the parser output right. We've ended up writing a couple of parsers for some custom XML inputs.

Seems to me that once a field is parsed out of a CSV file the expectation is to drupal_explode_tags() it into an array. How to put this into the configuration of a parser, I'm not sure. I tend to avoid CSV files when I can. This sort of things seems to belong better in a Feeds Tamper type of thing if it doesn't have a place in the parser. I'd love to see Feeds itself provide a tamper/alter/filter mechanism out of the box, like "Split taxonomy terms" using drupal_explode_tags(), that can be applied to anything - like any source field from any parser going to any multi-value target.

dynamicdan’s picture

Category: feature » task
Priority: Normal » Major

This solution worked for me:

// Handle non-multiple values.
if (!is_array($terms)) {
// !DD TODO : track this change!
//$terms = array($terms);
$terms = is_string($terms) ? drupal_explode_tags($terms) : array($terms);
}

Pity it's not in the core for v7.x.2 -alpha3 : (

BTW, I used CSV import with ; as the token separator and , for tags.

NickWebman’s picture

So... there is no way to fix this retroactively, right? I'll have to reimport everything?

cedarm’s picture

Right, you're commas are lost. It's been a while, but IIRC the problem is

    foreach ($terms as $k => $v) {
      // Make sure there aren't any terms with a comma (=tag delimiter) in it.
      $terms[$k] = preg_replace('/\s*,\s*/', ' ', $v);
    }

See #925264: Don't allow commas in tag names (and please test/review the patch!).

Agileware’s picture

Just to help others searching for a solution, make sure you check out http://drupal.org/project/feeds_tamper

brandy.brown’s picture

yes. #15 is the simplest solution to the problem. Of course that's a solution for Drupal 7...

asb’s picture

Version: 6.x-1.0-beta10 » 6.x-1.0-beta11

For programmers, there is the snippet from #2, and for D7 there is a patch mentioned in #15; also, there is an add-on module mentioned ('feeds_tamper') that theoretically could solve tons of shortcomings of the 'feeds' module (not just this bloody regression), but it appears to be unsupported (no response to issues in weeks), and it doesn't work at all for me.

Edit: Actually, only the "recommended" release of 'Feeds Tamper' doesn't work; the "Explode" plugin of feeds_tamper_6.x-1.x-dev from 2012-Apr-25 does the job in combination with feeds-6.x-1.0-beta11 from 2011-Jun-28.

Mark Vincent Verallo’s picture

For 7.x-2.0-alpha8+6-dev use the Feeds Tamper together with the Explode plugin.

flatcher’s picture

Issue summary: View changes
MegaChriz’s picture

Category: Task » Support request
Status: Active » Closed (fixed)

This request was answered ages ago. See #23.