I'm not sure if this is the correct/best place to put this. Please bear with me.

I'm attempting to populate a vocabulary (tags) from a text file I have. It has 2 columns, an nid in once column and a list of tags associated with the nid in the other column. I would like to populate drupal with all these tags and associate the nodes of interest with their respective tags.

I have written a script which works but is not perfect. It works like this:
1) search the 'term_data' table for the tag
2) If this term exists in 'term_data' get me the tid, if it does not exist, add it to the table and get me the tid
3) link the tid (obtained in step 2), vid (i know this), and nid (from my file) in the term_node table

So, this works as in, I can search my view by tag using these newly created tags. I can edit a node and see the tags which i inserted via my script/query above. Where it's not perfect is that if I go to 'list terms' of any of these vocabularies (Content Management -> Taxonomy), it does NOT show me the terms I inserted via my script, it only shows me terms which I entered manually in the node edit screen.

I'm thinking I need to add my tags to another table, but i'm not entirely sure if this is correct, how many tables, which tables, etc. Also, when I was playing around with a faceted search module, I could tell that something was not right in the DB. For example, let's say I have 5 nodes tagged with the word "cat". Faceted search should show me this:

cat (5)

but instead shows me this:

cat (1)
cat (1)
cat (1)
cat (1)
cat (1)

Any advice would be greatly appreciated. Thank you.

Comments

mkmaroon’s picture

anyone? please! need some help with this!

mattcasey’s picture

Why don't you post the script you are using? Are you assigning an existing Vocabulary to each new term? Perhaps there is already a function from the taxonomy module you can use to create terms...taxonomy_node_save()