How to import 'standard' field names using node import
The node_import module documentation discusses the need to contain a title and name (or uid) to integrate the imported information into Drupal so that it can be displayed. However, it doesn't provide other information that is important to taking maximum advantage of the capability.
I've looked through the forums and haven't found much help from other users of this module. One post described a set of other SQL fields that appear to be potentially usable by the import module (type, title, uid, status, comment, promote, users, revisions, created, changed, teaser, body), but it's not altogether clear whether all of those fields are accessible by node_import, or what their format should be for a succesful import. Additionally, there are other important, unanswered questions I have. A little advice from someone else on this forum that has experience with node import could probably save me from really messing up my own database. Could someone shine a little sunlight on the following questions:
- How can I enter values for taxonomy vocabularies associated with the node? For example, say I have a vocabulary of Fruit:{apples:{red,green},oranges,pears}. How is the vocabulary itself identified (does it end up with a field name of 'Fruit', for example). Then, how are values from that vocabulary identified (is the text entered, or position in the hierarchy).
- If the date-associated entries are not imported does the module default to today?
- What are the valid settings for 'type' - are these text values ("static", etc), or numbers
- Same disambiguation for status, promote?
- What is the expected import format for multiple nested comments (or is this not supported).
Thanks for the help!

Node Import Revisited
I just installed the node import (on Drupal 4.5) and inspite of the documentation saying it can import to any node, it seems the only options to import to are "contact" "event" and "raw data". Have I missed a setting.
Could anyone who has installed this module shed some light on this and previous questions.
Did you find your answers
Hi BryanPflug
I noticed you didn't get a reply. Did you ever resolve your issues? I am having a ton of problems with node import.
Partial answer
Since I'm struggling to do the same (importing a csv file with a flexinode content type), I'll share my findings until now, for Drupal 4.6 btw:
Let's assume a simple flexinode type with a URL as only field. Since it is the first flexinode type I make, it will get ctype_id = 1. And the field number is 1 also.
How can you find this out?
Well, one way is to look in the database:
Another way of finding this out is to go to the "edit" page of your content type. Look in the source, you'll find
<input type="hidden" name="edit[ctype_id]" value="1" />and
<input type="text" ... name="edit[flexinode_1]" id="edit-flexinode_1" ...>So, using this information, you now know some information for the node_import module:
Unfortunately this is not enough, you also need to specify:
In conclusion, to import milions of flexinodes using csv you need to make a csv file as follows:
title,name,type,ctype_id,flexinode_1"Foo Bar",admin,flexinode-1,1,http://www.example.org
"Foz Baz",admin,flexinode-1,1,http://www.example.com
Now, as for your questions:
Since I too have to import lots of stuff, I'll look into this soon again and will let this forum know. In the meantime, if anyone has answers, please let me know :-)
Kind regards,
Robrecht
Hack as solution for (1)
OK, I looked into the code of node_import.module and taxonomy.module to figure out how to add taxonomy terms to a flexinode import of a csv file.
node_import.module as such does not support this kind of thing. The reason for this is that the "taxonomy" field is an array and node_import only can set it to strings. taxonomy_nodeapi(insert) doesn't recognize this string as a list of terms, so it (silently) ignores to set it.
If you patch node_import.module, you could do it though, by "unserializing" some fields. I'll propose a patch to the node_import.module although maybe they won't like the solution.
The part that needs to be changed in node_import.module is:
<?phpfor ($c=0; $c < count($fields); $c++) {
$node->$fields[$c] = $data[$c];
}
$node = node_validate($node, $error);
?>
into:
<?phpfor ($c=0; $c < count($fields); $c++) {
if ( !is_integer( strpos( $fields[$c], "[]" ))) {
$node->$fields[$c] = $data[$c];
} else {
#try to unserialize if the fieldname ends with "[]"
$fname = substr( $fields[$c], 0, strpos( $fields[$c], "[]" ));
$node->$fname = unserialize( $data[$c] );
}
}
$node = node_validate($node, $error);
?>
With this patch, a csv file like:
title,name,type,ctype_id,flexinode_1,taxonomy[]"foo bar",Webmaster,flexinode-1,1,http://www.example.org,"a:2:{i:0;i:3;i:1;i:2;}"
"foz baz",Webmaster,flexinode-1,1,http://www.example.com,"a:1:{i:0;i:4;}"
will import the nodes and assign the taxonomy terms to it, assuming the numbers of the terms are correct of course.
Kind regards,
Robrecht
almost there
i want to handle array, but unserialize is not so friendly for those preparing import files. I prefer a pipe delimited string. nobody human ever uses a pipe character. we could escape those if necessary. the column name of any array field should be enclosed in brackets ... thats my preferred design. hopefully someone will build it now.
-moshe (maintainer of node_import)
I've prepared a patch. See:
I've prepared a patch. See: http://drupal.org/node/18207 (comment #7). It allows you to import something like:
"title", "name", "type", "body", "taxonomy[]""An example", "admin", "story", "no body", "1|2|3"
"Another example", "admin", "page", "http://www.example.org", "2|5"
Is this what you had in mind?
Robrecht
Getting data in
Thanks for this--this is the format that I need. The one remaining mystery is how node_import finds my CSV file. It doesn't have a file-upload button. I've tried FTPing the file (with various names guessed from the module's source code) into my "files" directory. Nothing happens--I just get a blank page. And no data is imported.
Thanks in advance for any tips.
Adam Rice
Re: Getting data in
I have an upload button for that. The only thing I can think of is the settings config for this module and maybe also for the upload module.
BTW: Thanks for this thread - it straightened out many of my ?-marks about importing info to Drupal.
Are you looking on the right page?
When you enable the module node_import, you get a link in your navigation: "node import". This is a simple form where you can upload your csv file. It has 2 buttons: "preview" and "import". "Preview" is just a debugging tool so you can see what is going on. Import imports it (duh!).
Don't you see this page?
Kind regards,
Robrecht
better noq
I did not, but I reinstalled, and now I do.
I want to play with the taxonomy-preservation patch now...
Adam Rice
Multiple fields in a flexinode.
Err. This is nice for a one field flexinode, but for a multiple field flexinode it won't work.
My answer has to be just writing a PHP script that generates the MySQL, and importing the queries for both flexinode_data and node.
You have to generate the previews, etc. This could be done more sensibly, but schedules to not permit an elaborate hack for submission.
KnowProSE.com
OpenDepth.comt
Verified: node_import does not import multiple fields
... into a flexinode. node_import is useless when it comes to that type of importation, especially since flexinode_data uses a 1:n relationship.
If there are future examples of how to import a flexinode successfully, I would suggest importing a flexinode with more than one field.
KnowProSE.com
OpenDepth.comt
And importing comments ... ?
Say you have a forum thread that you can export as a .csv: the first post is the article, and all subsequent posts are comments on the article. How can you deal with this kind of import whilst preserving the dates?
flexinode node_import multiple field import... partially
I was able to get it to import multiple fields, partially. Some worked, others didn't, not sure exactly why. But it's been mostly working for me after finding some threads like this one here.
I am using 4.7.2 with the latest CVS version of node_import.
--------------------
Michael
http://michaelangela.name