You are here

README.txt in Node import 5

Same filename in this branch
  1. 5 README.txt
  2. 5 supported/README.txt
  3. 5 supported/ecommerce/README.txt
Same filename and directory in other branches
  1. 6 README.txt
Drupal node_import.module README.txt
==============================================================================

This module allows you to import a set of nodes from a Comma Separated
Values (CSV) or Tab Separated Values (TSV) text file.

The module currently supports following types natively:
 * ecommerce tangible product (shippable product),
 * event,
 * page,
 * story,
 * weblink,
 * any node type created with the Content Creation Kit (CCK),
 * any flexinode node type.

Additionally it also has support for importing:
 * event-enabled nodes,
 * location-enabled nodes,
 * taxonomy-, or category-enabled nodes.

Installing node_import (first time installation)
------------------------------------------------------------------------------

1. Backup your database.

2. Copy the complete 'node_import/' directory into the 'modules/' directory of
   your Drupal site.

3. Enable the module from Drupal's admin pages (Administer >> Site building
   >> Modules). The needed tables will be automatically created.

   If the creation of the database tables fail, you can create them manually:

   CREATE TABLE node_import_mappings(
     type VARCHAR(16) NOT NULL DEFAULT '',
     csv_headers TEXT NOT NULL,
     mapping TEXT NOT NULL,
     KEY type(type)
   );

   Do not forget to prefix the table names if you use database table
   prefixing. Note that 'type' may be a reserved word for your database
   version. In this case you need to quote it:

   CREATE TABLE node_import_mappings(
     "type" VARCHAR(16) NOT NULL DEFAULT '',
     csv_headers TEXT NOT NULL,
     mapping TEXT NOT NULL,
     KEY "type"("type")
   );

4. Assign the 'import nodes' permission to the desired roles (Administer >>
   User management >> Access control) that are allowed to import nodes from
   a file. Note that the user will also need the correct permissions to
   create the nodes, eg 'create stories' to import 'story' nodes.

Upgrading node_import (on Drupal 4.7 or later)
------------------------------------------------------------------------------

1. Backup your database.

2. Remove the old 'node_import.module' or old 'node_import/' directory from the
   'modules/' directory of your Drupal site (possible after making a backup
   of it).

3. Copy the complete 'node_import/' directory into the 'modules/' directory of
   your Drupal site.

4. Go to the modules administration page (Administer >> Site building >>
   Modules) and select to run update.php.

   The data from the previous version will automatically be converted to
   the new format if needed.

Configuration
------------------------------------------------------------------------------

Give the roles which are allowed to import files the "import nodes" permission
on the access control administration page (Administer >> User management >>
Access control).

Users will not be able to import nodes of types which they are not allowed
to create, so you may need assign any of the "create XXXs" permissions too.

Node import wizard
------------------------------------------------------------------------------

The module provides a wizard at "Administer >> Content management >> Import
content" that walks the administrator or user through the import:

 1. The user selects the file to upload.

    This can either be a Comma Separated Values (CSV) or a Tab Separated
    Values (TSV) text file. The module will autodetect the format of the
    file if so set.

    It will autodetect a Tab Separated Values file if there is a tab-character
    on the first line.

 2. The user selects the node type she wishes to import this data into (for
    example 'page' or 'story').

    The user will only be able to select content types she has the right to
    create. The administrator will be able to import nodes of all types.

 3. The user maps the fields in the file to fields for the selected node
    type.

    The wizard shows the sample data of the first 5 rows to help her.

 4. The user selects some options for the import.

    The available options depend on the content type imported. See "Creating
    a file for node import" below.

 5. The user can then preview the nodes that would be imported and can make
    any change necessary by going back to previous pages.

 6. Finally, if all is well, the user can import the nodes.

After the import, the user may download a file with the rows from the
original file that failed to import.

Creating a file for node import
------------------------------------------------------------------------------

The module supports two file formats:

 - Comma separated values (CSV) text file,
 - Tab separated values (TSV) text file.

Both formats must contain one row of "column titles" as first row of the file.
These titles will be used in the "field mapping" step of the wizard (step
3 above).

Parsing a CSV file is handled by the "fgetcsv" function. This means that your
CSV file should use double quotes around strings that contain a comma. See
http://www.php.net/fgetcsv for details.

Note that the CSV file requires *comma's* for separating the columns, not
semicolons that Excel exports by default.

Any date you import should be a valid Unix timestamp (number of seconds
since January 1, 1970 00:00:00 GMT) or a string containing a valid US
English date format. See: http://www.php.net/strtotime.

Location options
****************

If the content type you import has locative information enabled on the
content type's workflow (Administer >> Content management >> Content types),
the module will allow you to import all locative information:

 - Location: Name,
 - Location: Street and Location: Additional address line,
 - Location: Postal code,
 - Location: City,
 - Location: State or province,

    This should either be a valid state or province code (such as
    'us-NY' for "New York, USA"), or the full English state or province
    name (such as "New York").

 - Location: Country,

   This should either be a two-letter country code such as 'be' for
   'Belgium' or 'ca' for 'Canada', or the full English country name
   such as 'Belgium' or 'Canada' (case-insensitive).

 - Location: Latititude,
 - Location: Longitude.

If you don't provide the longitude and latitude and location.module
has support for calculating the geocode for that country, then the
module will create the longitude and latitude automatically.

Node options
************

If the user doing the import has "administer nodes" permission, she will
be presented with the options to set the author and creation date as well
as the workflow options.

If the user does not have this permission, the nodes will be created with
the default workflow options, the current date as creation date and the
current user as the owner.

You can specify a user by name, email or uid.

Another option is "Titles must be unique for this node type". If this
option is checked, the import of a row will fail when there is already
another node of the same type with the same title.

Taxonomy options
****************

It is possible to assign taxonomy terms to nodes. For single select
vocabularies you need to put the name of the term in the column of the
file. For multiple select and free tagging vocabularies you can
specify multiple terms to be assigned to a node by separating them by
'|' (vertical bar).

So for example, if "multiple select" is a multiple select vocabulary and
"single select" is a single select vocabulary, you can put the following
in your (for example) CSV file:

  "title","body","single select","multiple select"
  "a title","some body text","term","term1|term2|term3"

This will create a node with 4 terms assigned to it:
 - the single select term "term"
 - three multiple select terms: "term1", "term2", "term3".

For a free tagging vocabulary you can use either '|' (vertical bar) or
',' (comma).

During import you will be presented with the option to add missing terms
to a vocabulary on the fly if you wish to do that. For example, consider
following Tab Separated Values file (here with spaces instead of tabs so
the columns are clear):

  title     body             single select   multiple select
  a title   some body text   term            term1|term2|term3

where "term3" does not exist in the "multiple select" vocabulary before
the import. If you select the option to "Add non-existing terms to the
vocabulary", "term3" will be added to "multiple select" vocabulary
before doing the import.

The options are:

 - "Add non-existing terms to the vocabulary" : if a term does not
   exist, the wizard will inform you during the preview that it will
   be created and it will create the term before importing the row.
   Note that if you have a single or multiple hierarchy vocabulary
   this term may not appear at the right spot in the hierarchy.

 - "Ignore non-existing terms" : if a term does not exist, the wizard
   will not warn you and the term will not be assigned to the node.

 - "Warn me about non-existing terms before the import" : if a term
   does not exist, the wizard will warn you about this during
   preview, but it will not consider non-existing terms an error.

 - "Do not import the node if there are non-existing terms" : if a
   term does not exist, the wizard will consider this an error and
   will not import that row.

If unsure, select "Do not import the node if there are non-existing
terms".

Category options
****************

If you use the category module instead of the taxonomy module for assigning
terms to nodes, you will need to have the taxonomy wrapper of the category
module installed and enabled.

In that case, category module will work the same as taxonomy module (so
see "Taxonomy options" above).

Event options
*************

You can import the start and end dates of event-enabled content types.
There are two ways for this:

 - either you specify in one column of the file the whole date,

 - or you specify a seperate column for the day, the month, the year,
   the hour and the minutes of as well the start and end dates.

Image support
*************

Added support for image module.

 * You need to upload the images to files/images before doing the import.

 * The content of the column you map to Image: Image must be the filename
   relative to files/images (or whatever you set the image directory
   path to).

For example:

 * Upload image1.jpg to files/images.

 * Import a CSV file like:

   "Title","Body","Image"
   "The title", "The body", "image1.jpg"

 * Map the Title column to the Title field, the Body column to the Body
   field and the Image column to the Image: Image field.

The image_gallery module is supported as well because it works with
taxonomy module. This means that you can create image galleries by
importing a CSV file like:

"Title","Body","Image","Image gallery"
"The title", "The body", "image1.jpg","The gallery"

Here you would map the Image gallery column to the Taxonomy: Image
galleries field.

Just like with taxonomy terms, you can assign a default image gallery
in the options or let Drupal create non-existing image galleries on
the fly (select Add non-existing terms to the vocabulary).

Upload (attachments) support
****************************

Added support for upload module.

 * Only one attachment can be specified.

 * You need to upload the file to files/ before doing the import.

 * The content of the column you map to Upload: File attachments must
   be the filename relative to files/ (or whatever you set the file
   directory path to).

For example:

 * Upload file1.txt to files/

 * Import a CSV file like:

   "Title","Body","File"
   "The title", "The body", "file1.txt"

 * Map the Title column to the Title field, the Body column to the Body
   field and the File column to the Upload: File attachments field.

Extending node_import
------------------------------------------------------------------------------

This module provides an easy API to permit any node type to be imported.  To
make your node type importable via this module, you must create 2 or more
functions, to tell which fields exist, etc.

See docs/node_import_hook_docs.php.

Bugs and shortcomings
------------------------------------------------------------------------------

 * NOT ALL FEATURES ARE FULLY TESTED.

 * See http://drupal.org/project/issues/node_import for a complete list of
   bugs and other problems.

 * The content types, users, taxonomy vocabularies, ... need to exist before
   starting the import. This module does not create content types!

Credits / Contact
------------------------------------------------------------------------------

The original author (version 4.5) of this module is Moshe Weitzman (weitzman).
Neil Drumm (drumm) rewrote the module for 4.6 (which he never released as
such).

The port of the module to 4.7 and some new features were provided by:
 - David Donohue (dado),
 - Nic Ivy (njivy).

The port to Drupal 5.x was made possible thanks to Daniel F. Kudwien (sun)
and Henrique Recidive (recidive).

Robrecht Jacques (robrechtj) is the current active maintainer of the module.

Best way to contact the developers to report bugs or feature requests is by
visiting the node_import project page at http://drupal.org/project/node_import.

If you have a problem with a specific file (CSV or TSV), it helps the authors
if you attach a (small) file that shows the problem. When you do, mention how
you configured the type you are trying to import, eg what vocabularies you
have defined, whether the content type is event- or location-enabled, etc.

File

README.txt
View source
  1. Drupal node_import.module README.txt
  2. ==============================================================================
  3. This module allows you to import a set of nodes from a Comma Separated
  4. Values (CSV) or Tab Separated Values (TSV) text file.
  5. The module currently supports following types natively:
  6. * ecommerce tangible product (shippable product),
  7. * event,
  8. * page,
  9. * story,
  10. * weblink,
  11. * any node type created with the Content Creation Kit (CCK),
  12. * any flexinode node type.
  13. Additionally it also has support for importing:
  14. * event-enabled nodes,
  15. * location-enabled nodes,
  16. * taxonomy-, or category-enabled nodes.
  17. Installing node_import (first time installation)
  18. ------------------------------------------------------------------------------
  19. 1. Backup your database.
  20. 2. Copy the complete 'node_import/' directory into the 'modules/' directory of
  21. your Drupal site.
  22. 3. Enable the module from Drupal's admin pages (Administer >> Site building
  23. >> Modules). The needed tables will be automatically created.
  24. If the creation of the database tables fail, you can create them manually:
  25. CREATE TABLE node_import_mappings(
  26. type VARCHAR(16) NOT NULL DEFAULT '',
  27. csv_headers TEXT NOT NULL,
  28. mapping TEXT NOT NULL,
  29. KEY type(type)
  30. );
  31. Do not forget to prefix the table names if you use database table
  32. prefixing. Note that 'type' may be a reserved word for your database
  33. version. In this case you need to quote it:
  34. CREATE TABLE node_import_mappings(
  35. "type" VARCHAR(16) NOT NULL DEFAULT '',
  36. csv_headers TEXT NOT NULL,
  37. mapping TEXT NOT NULL,
  38. KEY "type"("type")
  39. );
  40. 4. Assign the 'import nodes' permission to the desired roles (Administer >>
  41. User management >> Access control) that are allowed to import nodes from
  42. a file. Note that the user will also need the correct permissions to
  43. create the nodes, eg 'create stories' to import 'story' nodes.
  44. Upgrading node_import (on Drupal 4.7 or later)
  45. ------------------------------------------------------------------------------
  46. 1. Backup your database.
  47. 2. Remove the old 'node_import.module' or old 'node_import/' directory from the
  48. 'modules/' directory of your Drupal site (possible after making a backup
  49. of it).
  50. 3. Copy the complete 'node_import/' directory into the 'modules/' directory of
  51. your Drupal site.
  52. 4. Go to the modules administration page (Administer >> Site building >>
  53. Modules) and select to run update.php.
  54. The data from the previous version will automatically be converted to
  55. the new format if needed.
  56. Configuration
  57. ------------------------------------------------------------------------------
  58. Give the roles which are allowed to import files the "import nodes" permission
  59. on the access control administration page (Administer >> User management >>
  60. Access control).
  61. Users will not be able to import nodes of types which they are not allowed
  62. to create, so you may need assign any of the "create XXXs" permissions too.
  63. Node import wizard
  64. ------------------------------------------------------------------------------
  65. The module provides a wizard at "Administer >> Content management >> Import
  66. content" that walks the administrator or user through the import:
  67. 1. The user selects the file to upload.
  68. This can either be a Comma Separated Values (CSV) or a Tab Separated
  69. Values (TSV) text file. The module will autodetect the format of the
  70. file if so set.
  71. It will autodetect a Tab Separated Values file if there is a tab-character
  72. on the first line.
  73. 2. The user selects the node type she wishes to import this data into (for
  74. example 'page' or 'story').
  75. The user will only be able to select content types she has the right to
  76. create. The administrator will be able to import nodes of all types.
  77. 3. The user maps the fields in the file to fields for the selected node
  78. type.
  79. The wizard shows the sample data of the first 5 rows to help her.
  80. 4. The user selects some options for the import.
  81. The available options depend on the content type imported. See "Creating
  82. a file for node import" below.
  83. 5. The user can then preview the nodes that would be imported and can make
  84. any change necessary by going back to previous pages.
  85. 6. Finally, if all is well, the user can import the nodes.
  86. After the import, the user may download a file with the rows from the
  87. original file that failed to import.
  88. Creating a file for node import
  89. ------------------------------------------------------------------------------
  90. The module supports two file formats:
  91. - Comma separated values (CSV) text file,
  92. - Tab separated values (TSV) text file.
  93. Both formats must contain one row of "column titles" as first row of the file.
  94. These titles will be used in the "field mapping" step of the wizard (step
  95. 3 above).
  96. Parsing a CSV file is handled by the "fgetcsv" function. This means that your
  97. CSV file should use double quotes around strings that contain a comma. See
  98. http://www.php.net/fgetcsv for details.
  99. Note that the CSV file requires *comma's* for separating the columns, not
  100. semicolons that Excel exports by default.
  101. Any date you import should be a valid Unix timestamp (number of seconds
  102. since January 1, 1970 00:00:00 GMT) or a string containing a valid US
  103. English date format. See: http://www.php.net/strtotime.
  104. Location options
  105. ****************
  106. If the content type you import has locative information enabled on the
  107. content type's workflow (Administer >> Content management >> Content types),
  108. the module will allow you to import all locative information:
  109. - Location: Name,
  110. - Location: Street and Location: Additional address line,
  111. - Location: Postal code,
  112. - Location: City,
  113. - Location: State or province,
  114. This should either be a valid state or province code (such as
  115. 'us-NY' for "New York, USA"), or the full English state or province
  116. name (such as "New York").
  117. - Location: Country,
  118. This should either be a two-letter country code such as 'be' for
  119. 'Belgium' or 'ca' for 'Canada', or the full English country name
  120. such as 'Belgium' or 'Canada' (case-insensitive).
  121. - Location: Latititude,
  122. - Location: Longitude.
  123. If you don't provide the longitude and latitude and location.module
  124. has support for calculating the geocode for that country, then the
  125. module will create the longitude and latitude automatically.
  126. Node options
  127. ************
  128. If the user doing the import has "administer nodes" permission, she will
  129. be presented with the options to set the author and creation date as well
  130. as the workflow options.
  131. If the user does not have this permission, the nodes will be created with
  132. the default workflow options, the current date as creation date and the
  133. current user as the owner.
  134. You can specify a user by name, email or uid.
  135. Another option is "Titles must be unique for this node type". If this
  136. option is checked, the import of a row will fail when there is already
  137. another node of the same type with the same title.
  138. Taxonomy options
  139. ****************
  140. It is possible to assign taxonomy terms to nodes. For single select
  141. vocabularies you need to put the name of the term in the column of the
  142. file. For multiple select and free tagging vocabularies you can
  143. specify multiple terms to be assigned to a node by separating them by
  144. '|' (vertical bar).
  145. So for example, if "multiple select" is a multiple select vocabulary and
  146. "single select" is a single select vocabulary, you can put the following
  147. in your (for example) CSV file:
  148. "title","body","single select","multiple select"
  149. "a title","some body text","term","term1|term2|term3"
  150. This will create a node with 4 terms assigned to it:
  151. - the single select term "term"
  152. - three multiple select terms: "term1", "term2", "term3".
  153. For a free tagging vocabulary you can use either '|' (vertical bar) or
  154. ',' (comma).
  155. During import you will be presented with the option to add missing terms
  156. to a vocabulary on the fly if you wish to do that. For example, consider
  157. following Tab Separated Values file (here with spaces instead of tabs so
  158. the columns are clear):
  159. title body single select multiple select
  160. a title some body text term term1|term2|term3
  161. where "term3" does not exist in the "multiple select" vocabulary before
  162. the import. If you select the option to "Add non-existing terms to the
  163. vocabulary", "term3" will be added to "multiple select" vocabulary
  164. before doing the import.
  165. The options are:
  166. - "Add non-existing terms to the vocabulary" : if a term does not
  167. exist, the wizard will inform you during the preview that it will
  168. be created and it will create the term before importing the row.
  169. Note that if you have a single or multiple hierarchy vocabulary
  170. this term may not appear at the right spot in the hierarchy.
  171. - "Ignore non-existing terms" : if a term does not exist, the wizard
  172. will not warn you and the term will not be assigned to the node.
  173. - "Warn me about non-existing terms before the import" : if a term
  174. does not exist, the wizard will warn you about this during
  175. preview, but it will not consider non-existing terms an error.
  176. - "Do not import the node if there are non-existing terms" : if a
  177. term does not exist, the wizard will consider this an error and
  178. will not import that row.
  179. If unsure, select "Do not import the node if there are non-existing
  180. terms".
  181. Category options
  182. ****************
  183. If you use the category module instead of the taxonomy module for assigning
  184. terms to nodes, you will need to have the taxonomy wrapper of the category
  185. module installed and enabled.
  186. In that case, category module will work the same as taxonomy module (so
  187. see "Taxonomy options" above).
  188. Event options
  189. *************
  190. You can import the start and end dates of event-enabled content types.
  191. There are two ways for this:
  192. - either you specify in one column of the file the whole date,
  193. - or you specify a seperate column for the day, the month, the year,
  194. the hour and the minutes of as well the start and end dates.
  195. Image support
  196. *************
  197. Added support for image module.
  198. * You need to upload the images to files/images before doing the import.
  199. * The content of the column you map to Image: Image must be the filename
  200. relative to files/images (or whatever you set the image directory
  201. path to).
  202. For example:
  203. * Upload image1.jpg to files/images.
  204. * Import a CSV file like:
  205. "Title","Body","Image"
  206. "The title", "The body", "image1.jpg"
  207. * Map the Title column to the Title field, the Body column to the Body
  208. field and the Image column to the Image: Image field.
  209. The image_gallery module is supported as well because it works with
  210. taxonomy module. This means that you can create image galleries by
  211. importing a CSV file like:
  212. "Title","Body","Image","Image gallery"
  213. "The title", "The body", "image1.jpg","The gallery"
  214. Here you would map the Image gallery column to the Taxonomy: Image
  215. galleries field.
  216. Just like with taxonomy terms, you can assign a default image gallery
  217. in the options or let Drupal create non-existing image galleries on
  218. the fly (select Add non-existing terms to the vocabulary).
  219. Upload (attachments) support
  220. ****************************
  221. Added support for upload module.
  222. * Only one attachment can be specified.
  223. * You need to upload the file to files/ before doing the import.
  224. * The content of the column you map to Upload: File attachments must
  225. be the filename relative to files/ (or whatever you set the file
  226. directory path to).
  227. For example:
  228. * Upload file1.txt to files/
  229. * Import a CSV file like:
  230. "Title","Body","File"
  231. "The title", "The body", "file1.txt"
  232. * Map the Title column to the Title field, the Body column to the Body
  233. field and the File column to the Upload: File attachments field.
  234. Extending node_import
  235. ------------------------------------------------------------------------------
  236. This module provides an easy API to permit any node type to be imported. To
  237. make your node type importable via this module, you must create 2 or more
  238. functions, to tell which fields exist, etc.
  239. See docs/node_import_hook_docs.php.
  240. Bugs and shortcomings
  241. ------------------------------------------------------------------------------
  242. * NOT ALL FEATURES ARE FULLY TESTED.
  243. * See http://drupal.org/project/issues/node_import for a complete list of
  244. bugs and other problems.
  245. * The content types, users, taxonomy vocabularies, ... need to exist before
  246. starting the import. This module does not create content types!
  247. Credits / Contact
  248. ------------------------------------------------------------------------------
  249. The original author (version 4.5) of this module is Moshe Weitzman (weitzman).
  250. Neil Drumm (drumm) rewrote the module for 4.6 (which he never released as
  251. such).
  252. The port of the module to 4.7 and some new features were provided by:
  253. - David Donohue (dado),
  254. - Nic Ivy (njivy).
  255. The port to Drupal 5.x was made possible thanks to Daniel F. Kudwien (sun)
  256. and Henrique Recidive (recidive).
  257. Robrecht Jacques (robrechtj) is the current active maintainer of the module.
  258. Best way to contact the developers to report bugs or feature requests is by
  259. visiting the node_import project page at http://drupal.org/project/node_import.
  260. If you have a problem with a specific file (CSV or TSV), it helps the authors
  261. if you attach a (small) file that shows the problem. When you do, mention how
  262. you configured the type you are trying to import, eg what vocabularies you
  263. have defined, whether the content type is event- or location-enabled, etc.