I am using node import to pre-populate a CMS with up to 600 nodes. However, each node needs to fit into a hierarchy taxonomy structure - is node import capable of doing this and if so, how? Specifically I have managed to get the module to create taxonomy terms but am struggling with assigning child terms to parent terms.
The vocabulary is a multiple hierarchy type but not multiple select. Below is a snippet of what the hierarchy looks like:
p1
-section A
--general
---proposal cover
---proposal form
---vipp statement
----appendix 1
---conflict of interest
-section B
--departure schedules
---design departures
---commercial departures
----clean copies of agreement
-----deed
-----project agreemnt
p2
-section C
--general
Any kind of help in this regard would be massively appreciated.
many thanks in advance,
Ole
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | Counties_townships_tax_xml_module.txt | 140 bytes | kbk |
| #27 | Counties_townships_arrows.txt | 87 bytes | kbk |
| #27 | Counties_townships.txt | 99 bytes | kbk |
| #22 | node_import_fix_hierachy.patch | 65.97 KB | mario_prkos |
Comments
Comment #1
germandrupaller commentedThat's exactly what I am looking for, too.
Comment #2
tvoorter commentedNode import can map the categories into your taxonomy structure. I use this module every month to import about 1000 titles with each 3 vocabularies and underlying terms, sometimes 4 levels deep. I work with categories from the BIC Bibliographic Standards Group. See for a working example: http://www.newasiabooks.org/index.php?q=node/2998 (at the bottom of the page you see the structure). It all goes automatically.
cheers .. Thomas
Comment #3
germandrupaller commentedAnd how? I cant get it to work.
Comment #4
germandrupaller commentedAnd how? I cant get it to work.
Could you give a quick walk thtough please - thanks a lot!
Comment #5
gagarine commentedtrack... be useful for ubercart! http://www.ubercart.org/forum/general_discussion/2933/node_import_module...
Comment #6
gagarine commentedYou can do that with "pipe" like: cat1name|cat2name (thanks kcoworks)
But in my case, the hierarchy are present only on drupal (for web site). On my csv file i have only the name of the target term. How can i map it?
EX:
term on my csv
apple
banana
cats
mango
term on my durpal site
Fruit
- apple
- banana
- mango
Animal
-cats
EDIT:
Yeah it's automagically ! You can't add term in the hierarchy (logic..) but if you have already a term with the same name the mapping are automatic even you have no pipe.
-perfect world-
Comment #7
liquidcms commentedI was a bit confused looking at this and i see i have 2 different import situations here:
2 Tables:
- product
- category
category is a parent child like table of terms used to tag products
so basically:
product table: id, title, body, catid
category: id, title, pid (parentid)
Since the Drupal version of all this will have a hierarchical structure already for the terms, it is only necessary to import product table and assign catid (actually the category title from a join on catid) to taxonomy for that container. I just tried this and it works like a charm since not really any structure involved.
The tricky part is to import the category table into something that creates the parent/child term relationships. Is that possibly what is being discussed here with using |'s.
Now to add an extra level of complexity to all this - i am using the category.module's category_transform.module (which is similar to the NAT (node auto term) module) which basically uses nodes as terms. So for me; i actually do need to import categories into nodes - and hopefully have it recognize hierarchy when it makes the terms to match this - but i think that would be pretty wishful thinking..
Comment #8
Fayna commentedWould anyone be willing to write up some documentation on this? I couldn't find this info on the current handbook pages for Node import.
Comment #9
liquidcms commentedlikely no info in handbook since what i have been talking about is "out of the scope" of this module.
The way i eventually did all this was to use the "hook" idea that is supported by the node import module - since it does a node submit before doing a node save it is possible to write node_submit hook code to "look" at the node you are about to save and set other values based on whatever you want.
in my case, as i mentioned, i needed to set the new category/nodes parent based on info i get from the original table.
works like a charm, but.. clearly this is beyond the abilities of many budding drupal users - but then so is db import in general
Comment #10
gthing commentedpiping is not a proper solution - at least not for me.
adding cars|honda would simply add two parent terms to my taxonomy, and place the node in both categories.
Comment #11
gthing commentedI thought of an easy way that nested taxonomy could be implemented into node import. Simply by adding a few child fields beyond the main taxonomy field.
So for example, the script currently generated a category based on the field it's given and places it under the vocabulary you have selected in the import options.
So if you had in your CSV something like
cars, honda, civic
The script would simply run an extra taxnomy creation statement for each one, replacing the parent vocabulary with the category name from the previous statement.
Does that make sense?
You could add support for something like 3 children, giving a total of supporting nested taxonomies that are 4 deep. Such as
Cars, Honda, Civic, 2001
or whatever...
Comment #12
giorgio79 commentedCannot node import module call taxonomy_csv module or taxonomy_xml import and import hierarchical taxonomies that way? And while saving the node, assign the node to the previously created lowest level term of the hierarchical category?
Comment #13
zeezhao commentedSubscribing to this, to know what the latest solution is for this issue. Thanks
Comment #14
cwittusen commentedI'm also looking to do what tvoorter did but never came back to describe how he did it; I got a hierarchy category setup as listed below and need help with my cvs as well.
How do I separate them from each top category, my structure is as listed below and I want a product to only be in baby girl->sets->0-3 Months for instance. When I use the | it sticks it into the Baby Boy instead.
Baby boy
-Top
--0-3 Months
--3-6 Monhts
-Pants
--0-3 Months
--3-6 Monhts
Baby girl
-Top
--0-3 Months
--3-6 Monhts
-Pants
--0-3 Months
--3-6 Monhts
I have looked for a solution high and low but with no result; any help would be greatly appreciated.
/Chris
Comment #15
Anonymous (not verified) commentedsub
Comment #16
yhager commentedsubscribing
Comment #17
marie_t commentedsubscribing
Comment #18
yurtboy commentedooops I thought the below was working but not if the taxonomy was not created already..sorry about that.
Will this help
if you open the csv file you would see...
"e","t","cn"
15,"Mammal | Sirenia | Trichechus | manatus","Florida Manatee"
16,"Bird | Sphenisciformes | Aptenodytes | patagonicus","King Penguin"
When the imports are done you get
Taxonomy Group will populate
Mammal
--Sirenia
----Trichechus
------manatus
Bird
--Sphenischiformes
----Aptenodytes
------patagonicus
These are made and the node
King Penguin would then be taxonomy Bird and Sphen and Apten and Para
Comment #19
yurtboy commentedI wrote a quick how to here
http://drupal.org/node/369332
It took care of the multi level taxonomy limitation.
Comment #20
ldbl commentedI'm trying to import node with hierarchical taxonomy .
I have >> sign in my CSV file for parent >> child.
But every time when i try to import node with taxonomy i receive the following error:
ot step 7 where is the previe -
warning: mb_strlen() expects parameter 1 to be string, array given in C:\webdev\apache\Apache2\htdocs\farove\includes\unicode.inc on line 404.
And no taxonomy imported at all.
How can I import hierarchical taxonomy to node ?
Any help will be appreciated.
Comment #21
mario_prkos commentedsubscribe
Comment #22
mario_prkos commentedThis is patch for fixing problem with hierarchical taxonomy. You have to patch node_import.inc file in rc4 version?
If you have any problem you can contact me!
Comment #23
osmanI have a quite large CSV file which I use to to create nodes using node_import, +16,000 records.
I would like to use the same CSV to populate taxonomy terms as well, preferable without altering the CSV.
For the vocabulary I need to use only three fields of this CSV: Name, County, State
I already have a working hierarchical vocabulary containing all the States and some of the counties.
My goal is to import "Name" field as the 3rd level term into this vocabulary:
State
-County
--Name
Map file columns (step 4 of 8)
Synonyms: None
Weight: None
Related terms: None
Parents: County
Term name: Name
Description: None
Set import options (step 5 of 8)
Parents Hierarchy is specified by:
Preview import (step 7 of 8)
warning: mb_strlen() expects parameter 1 to be string, array given in /domains/example.com/html/includes/unicode.inc on line 404.Can't I use the my existing CSV without altering it?
Thanks,
Comment #24
summit commentedSubscribing, greetings, Martijn
Comment #25
osmanI just read the advanced help documentation. I got my answer, even I don't like it.
I highly recommend reading it. :-)
Comment #26
funkeyrandy commentedwhat was solution to this? seems like it can map terms, but cannot CREATE the tree if it has not been created yet...plz advise
Comment #27
kbk commentedI don't know that this is solved. I tried out the patch, which appears to be the same as 6.x-1.x-dev, and had no luck trying to populate a vocabulary with parents and children. The children show up but the parents are slung in netherspace.
I've attached my csv file(s) if anyone can spot an error. "County" is the parent of "Township". Counties_townships_arrows.txt is my interpretation on how to use " >>" to establish the parent child relationship; no doubt this is probably wrong.
BTW, the advanced help is located here (I always have problems finding it when I need it!): /admin/advanced_help/node_import
Comment #28
funkeyrandy commentedthat patch crashed my rc4 install...anyone help here?
Comment #29
kbk commentedTry the 6.x-1.x-dev version. I would be interested to know if that helps with your problem.
Comment #30
kbk commentedIf your goal is to create a hierarchical vocabulary you might have better luck with the taxonomy xml module. It allows for a csv import as well. Assuming node import creates the relations between a content type and a vocabulary term correctly (versus creating the actual vocabulary) the two modules would complement eachother. A 1-2 punch, if you will.
The attached file is the format I used to populate a vocabulary with hierarchical terms in the taxonomy xml module. This page has more on formatting options.
Comment #31
ch_masson commentedHello osman,
Could you please share your findings when reading the advanced help. I just spent 2 hours reading it very carefully but unfortunately did not find anything that might help me.
Thanks,
Christian
Comment #32
webdeli commentedIt is important to ensure that your taxonomy's hierarchy column in the vocabulary table is set to '1' not '0' in the database. Check it with phpMyAdmin, command line or other database UI of your choice.
Comment #33
graytoby commentedwebdeli, you just saved my day.
Comment #34
xdecibelx commentedWebdeli, I'm buying you a beer!