TIBCO EBX®
Documentation > User Guide > Datasets > File import and export services
Navigation modeDocumentation > User Guide > Datasets > File import and export services

CSV import and export

Introduction

CSV imports and exports can be performed on tables through the user interface using the Actions menu in the workspace.

Both imports and exports are performed in the context of a dataset.

Imports and exports can also be done programmatically.

Default import and export option values can be set in the Administration area, under User interface > Graphical interface configuration > Default option values > Import/Export.

Exports

When exporting to CSV, if the table has filters applied, only the records that correspond to the filter are included in the exported file.

The CSV export options are as follows:

Download file name

Specifies the name of the CSV file to be exported. This field is pre-populated with the name of the table from which the records are being exported.

File encoding

Specifies the character encoding to use for the exported file. The default is UTF-8.

Enable inheritance

In order to consider the inheritance during a CSV export, the option has to be defined in the model.

For more information on inheritance, see Inheritance and value resolution.

Specifies if inheritance will be taken into account during a CSV export.

If inheritance is enabled, resolved values of fields are exported with the technical data that define the possible inheritance mode of the record or the field.

If inheritance is disabled, resolved values of fields are exported and occulted records are ignored.

By default, this option is disabled.

Note: Inheritance is always ignored, if the table dataset has no parent or if the table has no inherited field.

User-friendly mode

Specifies whether exported values will be represented in a user-friendly way, or in a raw format. For example, in user-friendly mode, dates and numbers are formatted according to the user's locale, and foreign keys and enumerated values display their associated labels.

Note: If this option is selected, the exported file will not be able to be re-imported.

Include technical data

Specifies whether internal technical data will be included in the export.

Note: If this option is selected, the exported file will not be able to be re-imported.

Column header

Specifies whether or not to include column headers in the CSV file.

  • No header

  • Label: For each column in the spreadsheet, the CSV displays its label. Each label is localized according to the locale preference of the current session. If no user-friendly label is defined for a node, the technical name of the node is used.

  • XPath: For each column in the spreadsheet, the CSV displays the path to the node in the table.

Field separator

Specifies the field separator to use for exports. The default separator is comma, it can be modified under Administration > User interface.

List separator

Specifies the separator to use for values lists. The default separator is line return, it can be modified under Administration > User interface.

Programmatic CSV exports are performed using the classes ExportSpec and ExportImportCSVSpec in the Java API.

Imports

Download file name

Specifies the name of the CSV file to be imported.

Import mode

When importing a CSV file, you must specify one of the following import modes, which will control the integrity of operations between the source and the target table.

  • Insert mode: Only record creation is allowed. If a record exists in the target table with the same primary key as the source record, an error is returned and the whole import operation is cancelled.

  • Update mode: Only modifications of existing records are allowed. If no record exists in the target table with the same primary key as the source record, an error is returned and the whole import operation is cancelled.

  • Update or insert mode: If a record with the same primary key as the source record already exists in the target table, that record is updated. Otherwise, a new record is created.

  • Replace (synchronization) mode: If a record with the same primary key as the source record already exists in the target table, that record is updated. Otherwise, a new record is created. If a record exists in the target table but is not present in the source XML file, that record is deleted from the table.

File encoding

Specifies the character encoding to use for the exported file. The default is UTF-8.

Enable inheritance

In order to consider the inheritance during a CSV import, the option has to be defined in the model.

For more information on inheritance, see Inheritance and value resolution and ExportImportCSVSpec.setInheritanceEnabled.

Specifies whether the inheritance will be taken into account during a CSV import. If technical data in the CSV file define an inherit mode, corresponding fields or records are forced to be inherited. If technical data define an occult mode, corresponding records are forced to be occulted. Otherwise, fields are overwritten with values read from the CSV file. By default, this option is disabled.

Note: Inheritance is always ignored if the dataset of the table has no parent or if the table has no inherited field.

Column header

Specifies whether or not to include column headers in the CSV file.

  • No header

  • Label: For each column in the spreadsheet, the CSV displays its label. Each label is localized according to the locale preference of the current session. If no user-friendly label is defined for a node, the technical name of the node is used.

  • XPath: For each column in the spreadsheet, the CSV displays the path to the node in the table.

Field separator

Specifies the field separator to use for exports. The default separator is comma, it can be modified under Administration > User interface.

List separator

Specifies the separator to use for values lists. The default separator is line return, it can be modified under Administration > User interface.

Programmatic CSV imports are performed using the classes ImportSpec and ExportImportCSVSpec in the Java API.

Handling of field values

Aggregated lists

The CSV import and export services support multi-valued fields, namely aggregated lists. This is only supported for simple typed lists, such as lists of string, date, or int, and for foreign keys. If a table reference is linked to a composite primary key, each item in the list is a formatted string, for example, "true|99". Aggregated lists of groups are not exported.

At export, the items in the list are separated using line separators. In cases where the exported field already contains a line separator, for example in an osd:html or an osd:text, the code _crnl_ is inserted in place of the field value's line separators. The same formatting is expected at import, with the whole field value surrounded by quotes.

Hidden fields

Hidden fields are exported as ebx-csv:hidden strings. An imported hidden string will not modify a field's content.

'Null' value for strings

Using CSV import and export services, a string with a value set to null is exported as an empty string. Therefore, a round trip export-import procedure will end up replacing null string values with empty strings.

Using programmatic services, the specific value ebx-csv:nil can be assigned to strings with values set to null. If this is done, the null string values will not be replaced by empty strings during round trip export-import procedures. See ExportImportCSVSpec.setNullStringEncoded in the Java API for more information.

Date, time & dateTime format

The following date and time formats are supported:

Type

Format

Example

xs:date

yyyy-MM-dd

2007-12-31

xs:time

HH:mm:ss or HH:mm:ss.SSS

11:55:00

xs:dateTime

yyyy-MM-ddTHH:mm:ss or yyyy-MM-ddTHH:mm:ss.SSS

2007-12-31T11:55:00

Known limitations

Aggregated lists of groups

The CSV import and export services do not support multi-valued groups, that is, aggregated lists of complex type elements. Exporting such nodes will not cause any error, however, no value will be exported.

Terminal groups

In a CSV file, it is impossible to differentiate a created terminal group that contains only empty fields from a non-created one.

As a consequence, some differences may appear during comparison after performing an export followed by an import. To ensure the symmetry of import and export, use XML import and export instead. See XML import and export.

Column label headers

If two columns share the same label header, an export of the table can be performed successfully, but exported data cannot later be re-imported.

Association fields

The CSV import and export services do not support association values, i.e. the associated records.

Exporting such fields will not cause any error, however, no value will be exported.

Importing such fields will cause an error and the import procedure will be aborted.

Selection nodes

The CSV import and export services do not support selection values, i.e. the selected records.

Exporting such fields will not cause any error, however, no value will be exported.

Importing such fields will cause an error and the import procedure will be aborted.

Documentation > User Guide > Datasets > File import and export services