Import / Export API Reference: csv engines

This document provides a programmer's reference to the csv get and csv put engines of the Drupal Import / Export API. For an explanation of the field types and their core properties, see the main Import / Export API reference document.

Skip to: Properties

Fields and properties matrix

Legend:
X = property can be used with this field type
- = this property is not applicable to this field type

#type array datetime entity file float freeform int serialized string
#csv_hidden - X - X X X X X X
#csv_mapping - X - X X X X X X
#csv_plural X - X - - - - - -

Properties

#csv_hidden

Used by: ALL types except entity, array.

Description: When set to TRUE, indicates that this field should not be outputted during a csv 'put' operation.

Values: Boolean.

Default value: NULL

Usage example: (importexportapi_comment.inc):

<?php
$def
['comment_statistics_nid'] = array(
 
'#type' => 'int',
 
'#title' => t('Node ID'),
 
'#reference_entity' => ,
 
'#reference_field' => array('nid'),
 
'#db_table' => 'node_comment_statistics',
 
'#db_field_unaliased' => 'nid',
 
'#key_component' => TRUE,
 
'#csv_hidden' => TRUE
);
?>

#csv_mapping

Used by: ALL types except entity, array.

Description: The CSV column heading name for this field. During a 'put' operation, the values of this field will be outputted in a column underneath this name; and during a 'get' operation, the system will search for a column with this name. This should NOT be confused with the #csv_plural property, which applies to CSV file names.

Values: A valid CSV column heading name. Note: this value must be unique for all direct child fields of a given entity or array.

Default value: inherited from the #id property of this field.

Usage example: (importexportapi_menu.inc):

<?php
$def
['path'] = array(
 
'#title' => t('System path'),
 
'#xml_mapping' => 'system-path',
 
'#csv_mapping' => 'system-path',
 
'#unique' => TRUE
);
?>

#csv_plural

Used by: entity, array.

Description: The CSV file name for this field. During a 'put' operation, the values of the direct children of this field will be outputted to a file (or to a portion of the screen) with this name; and during a 'get' operation, the system will search for files with this name. This property should NOT be confused with the #csv_mapping property, which applies to the column heading names for fields within files.

Values: A valid file name. Note: this value must be unique for all fields to which it applies.

Default value: inherited from the #id property of this field.

Usage example: (importexportapi_node.inc):

<?php
$def 
= array(
 
'#type' => 'entity',
 
'#title' => t('Node'),
 
'#db_default_table' => 'node',
 
'#xml_plural' => 'nodes',
 
'#csv_plural' => 'nodes'
);
?>