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

Comments

germandrupaller’s picture

That's exactly what I am looking for, too.

tvoorter’s picture

Node 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

germandrupaller’s picture

And how? I cant get it to work.

germandrupaller’s picture

And how? I cant get it to work.

Could you give a quick walk thtough please - thanks a lot!

gagarine’s picture

gagarine’s picture

You 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-

liquidcms’s picture

I 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..

Fayna’s picture

Would anyone be willing to write up some documentation on this? I couldn't find this info on the current handbook pages for Node import.

liquidcms’s picture

likely 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

gthing’s picture

piping 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.

gthing’s picture

I 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...

giorgio79’s picture

Cannot 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?

zeezhao’s picture

Version: 5.x-1.2 » 5.x-1.7

Subscribing to this, to know what the latest solution is for this issue. Thanks

cwittusen’s picture

I'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

Anonymous’s picture

sub

yhager’s picture

subscribing

marie_t’s picture

subscribing

yurtboy’s picture

ooops 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

yurtboy’s picture

I wrote a quick how to here
http://drupal.org/node/369332
It took care of the multi level taxonomy limitation.

ldbl’s picture

I'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.

mario_prkos’s picture

subscribe

mario_prkos’s picture

Version: 5.x-1.7 » 6.x-1.0-rc4
Component: Miscellaneous » Code
Assigned: Unassigned » mario_prkos
StatusFileSize
new65.97 KB

This 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!

osman’s picture

I 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,

summit’s picture

Subscribing, greetings, Martijn

osman’s picture

I just read the advanced help documentation. I got my answer, even I don't like it.

I highly recommend reading it. :-)

funkeyrandy’s picture

what was solution to this? seems like it can map terms, but cannot CREATE the tree if it has not been created yet...plz advise

kbk’s picture

Issue tags: +taxonomy, +node import
StatusFileSize
new99 bytes
new87 bytes

I 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

funkeyrandy’s picture

that patch crashed my rc4 install...anyone help here?

kbk’s picture

Try the 6.x-1.x-dev version. I would be interested to know if that helps with your problem.

kbk’s picture

Issue tags: +taxonomy xml
StatusFileSize
new140 bytes

If 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.

ch_masson’s picture

Hello 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

webdeli’s picture

It 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.

graytoby’s picture

webdeli, you just saved my day.

xdecibelx’s picture

Webdeli, I'm buying you a beer!