Hi,

Is it possible to node_import csv data with taxonomy terms and sub-term?

Example:
Having a voc named "Colors"
-Red
--light Red
--Dark Red
-Brown
--Light Brown
--Dark Brown

I'm going to import this

"title", "body", "Colors"
"title 1", "body 1", "Red"
"title 2", "body 2", "Red--Light Red"
"title 3", "body 3", "Brown--Light Brown"

in this example the '--' stands for 'a sub term follows'

how should be formatted the csv row?

thanks

Comments

afagioli’s picture

In the example above, terms should be created by the import himself, eventually using the free tagging option
Thanks

germandrupaller’s picture

is this a duplicate of "taxonomy hierarchy" that is many weeks old and still not answered?

I'm really curious about a solution for creating parent and child terms from term1|term2|term3 - where 2 is the child 1 and 3 the child of 2.

afagioli’s picture

Still waiting for a proper solution, I've found a workaround where the csv data is something like "term__subterm".
After importing nodes, the free-tagging vocubolary is populated.
Now, a sql script will run in term_ tables updating terms label and parent

I'm quite sure there must be a better solution, anyway.

germandrupaller’s picture

still no solution ... ;(

summit’s picture

Subscribing. May be taxonomy_xml import for taxonomies a better solution?
greetings,
Martijn

afagioli’s picture

Yes, it is.
With your solution, we should go for a "two steps import process".
And we don't want this, do we?

summit’s picture

Hi,

I see something using the piping character '|'.
Is it possible to tag a node hierarchical witn a new term using the following logic?

parentterm|new-childterm

Thanks in advance for your reply!

Greetings,
Martijn

zahor’s picture

If it's just taxonomy terms you need to import in this way (and not the relating nodes), I'd just use sql scripts to do it. It took me a long time to get it right, but really only takes a few mins to do.

summit’s picture

Hi Zahor,

Could you post your sql-script here please?
Thanks in advance!
greetings,
Martijn

liquidcms’s picture

yes, i'd love it if there was some way to import hierarchical taxonomy but aren't most other systems going to have something like my case:

my product table simply has a category id number associated with it - then in another table for the hierarchy it defines parent/child relationships.

but i guess easy to make a joined sql off old table to create something like:

title, body, parent|child|subchild

so yes, something that could handle this would be very powerful

kingandy’s picture

FWIW, in my experience, the easiest thing is to populate the taxonomy first and then import the nodes, using the final category (ie, the category that the node will be 'in') as the field in the spreadsheet.

In the example provided above, once your vocab has been created you'd generate a spreadsheet like so:

"title", "body", "Colors"
"title 1", "body 1", "Red"
"title 2", "body 2", "Light Red"
"title 3", "body 3", "Light Brown"

Node Import should drop your nodes into the correct categories - it doesn't need to know where in the vocabulary tree the category is. It helps that in this case the category names are distinct ... if you had a category structure like 'colors / red / light' and 'colors / brown / light' you'd be up the creek as there's no way of expressing to Node Import which 'Light' category you're talking about. But then, that category structure would be only semi-functional in vanilla Drupal anyway, since it only displays solitary names on the default node page.

Hope that makes sense.

giorgio79’s picture

Hi,

I am not sure I understand.

If I have a hierarchical category with terms, at least I would need to be able to specify the term where I want to attach the node. Specifying the category only would do me no good :)

But so far it seems I need to have the taxonomy hieararchy with taxonomy csv first for example. It would be nice to be able to automate this whole process.

giorgio79’s picture

By the way, this issue is almost the same

http://drupal.org/node/162474

afagioli’s picture

Status: Active » Closed (fixed)

closed per inactivity

gurayc’s picture

Use this csv form,

I tested and it works,

"title", "body", "Colors"
"title 1", "body 1", "Red"
"title 2", "body 2", "Light Red>>Red"
"title 3", "body 3", "Light Brown>>Brown"

Also set this values on import step 5/8

"Multiple values are seperated from : >>"

"Hierarcy is specified by : >>"