I use the explode plugin to create an array of taxonomy terms from the following string structure
"""aaa"",""b,b,b"",""c,c,c"""
I then use REGEX /"(.*)"/s and replace with $1 to remove the quotes
PROBLEM comes when the input list of terms is blank/empty
explode creates an array with an empty string element.
Unfurtunately this then creates a taxonomy entry with a blank term.
SOLUTION
here is the code change in explode.inc which works for me.
function feeds_tamper_explode_callback($result, $item_key, $element_key, &$field, $settings) {
//dsm($field);
$pos= strpos($field, $settings['real_separator']); // returns FALSE when separator NOT in field ... eg empty field
if ( $pos !== FALSE ) {
$field = explode($settings['real_separator'], $field);
}
//dsm($field);
}
Sorry I was not easily able to create a patch. I hope there is someone better equipped than I to do the next steps and get this change into the dev version.
Thanks
Comment | File | Size | Author |
---|---|---|---|
#20 | port_array_filter_w_tests-1180726-20.patch | 1.87 KB | 5n00py |
#19 | port_array_filter_tests_to_6.x-1180726-19.patch | 1.01 KB | 5n00py |
#18 | port_array_filter_to_6.x-1180726-18.patch | 881 bytes | 5n00py |
#11 | feeds_tamper-array_filter_plugin-1180726-11.patch | 852 bytes | nchar |
#6 | empty_check-1180726-6.patch | 530 bytes | 5n00py |
Comments
Comment #1
twistor CreditAttribution: twistor commentedThis got fixed at some point.
Comment #3
Steven.Pescador CreditAttribution: Steven.Pescador commentedSorry to reopen this, but experienced this problem today using the latest dev version.
If my imported field is empty, explode is creating an array with an empty string element and in turn this is creating a blank taxonomy term.
I got it working myself using...
But this is probably an extremely dirty solution and may cause other errors. Just thought I'd throw this out here to see if I was missing something or more likely doing something wrong. Cheers.
Comment #4
TimelessDomain CreditAttribution: TimelessDomain commented#3 works - thanks. I was getting blank fields (taxonomy + any other exploded field) when exploding a csv parser, but now i don't. Yay!
Comment #5
EvanDonovan CreditAttribution: EvanDonovan commentedCan someone turn this into a patch so that it could get applied to the module? Also, are the posts from #3 on saying that this is still an issue on 7.x?
Also is this an issue on 6.x too?
Comment #6
5n00py CreditAttribution: 5n00py commentedModified solution from #3 packed to patch! Works fine for me.
Comment #7
reszli#6 - thanks for this, it works!
Comment #8
5n00py CreditAttribution: 5n00py commentedWhy we have not any progress? Who can apply\review patch?
Comment #9
twistor CreditAttribution: twistor commentedI know I haven't committed this yet, here is my reasoning:
The empty value your're seeing is in the source data, so removing it automatically might not be wanted. For example, if you have a multi-columned field, like an address field. It has columns like, street, state, city, country, etc. In the source data, some of these entries might not be filled in. If we filter out empty values, then the columns won't align properly anymore.
My proposed solution is to create a new plugin, something like array_filter, which will remove empty values from the array.
Comment #10
5n00py CreditAttribution: 5n00py commentedOk.
But maybe we can add an option to existing explode plug-in?
Just something like "keep empty values"?
Comment #11
nchar CreditAttribution: nchar commentedI created the array_filter plugin, that Chris suggested as the best solution. It works fine for me!
Comment #12
liquidcms CreditAttribution: liquidcms commentedi have a multi user ref field which i was tampering with explode, trim. empty values in the csv were causing the error: "is not a valid user" due to the explode causing an empty array.
using the array_filter plugin from the patch in #11 fixed this. thanks.
Comment #13
5n00py CreditAttribution: 5n00py commentedReview from coder module:
Also patch can't be applied as is to 7.x branch. because it require empty file.
So make another diff by running:
git diff origin/7.x-1.x
Header may look like this one:
As functionality, I tested this plugin on clean installation and it works properly.
It do not change any explode code, its only new plugin.
So it can be applied after this little fixes.
Thank for the patch, waiting for fixing this little issues and commit.
Comment #14
twistor CreditAttribution: twistor commentedI went ahead and fixed the small things.
Thanks!
http://drupalcode.org/project/feeds_tamper.git/commit/1c491d6
Comment #15
phiscock CreditAttribution: phiscock commentedI've tried using the new plugin in the dev version, but it does not seem to be having any effect. I've tried applying it both before and after the explode plugin on text fields with multiple values.
Am I using it wrongly or is it not working for other people.
Paul
Comment #16
liquidcms CreditAttribution: liquidcms commenteduse after explode. and it works fine.
Comment #17
phiscock CreditAttribution: phiscock commentedThanks. I was looking at previously wrongly imported data that was still there when I thought it didn't work.
Comment #18
5n00py CreditAttribution: 5n00py commentedPatch for 6.x branch attached.
Very same as 7.x version.
Included update from http://drupalcode.org/project/feeds_tamper.git/commit/372d17384195c02a9d...
(http://drupalcode.org/project/feeds_tamper.git/blobdiff/1c491d638e78a06b...)
Tests are not included.
I'm already test plugin on fresh d6 installation and it work properly.
Only one problem is a another feeds_tamper bug. (Now feeds tamper not support plugins without settings).
This problem appear in unique.inc plugin also.
Comment #19
5n00py CreditAttribution: 5n00py commentedTests patch. It needs review because I have not experience with tests.
Comment #20
5n00py CreditAttribution: 5n00py commentedPrev 2 patches in one file.
Comment #21
twistor CreditAttribution: twistor commentedThanks.
Comment #26
twistor CreditAttribution: twistor commentedComment #29
5n00py CreditAttribution: 5n00py commentedThis patch already commited, so it can't be applied.
@msizec: If you have some problems with this patch you can reopen this issue or create new one, but you should provide some information.