Create a Dataset Using a CSV File

Publisher supports datasets that use CSV file data sources to return valid XML data.

The following topics describe using requirements and procedures for using a CSV as a data source:

About Supported CSV Files

Support of CSV files as a dataset type in Publisher follow certain guidelines.

  • You can use a CSV file that is located in a directory that your administrator has set up as a data source.

    You can upload a file from a local directory.

  • The supported CSV file delimiters are Comma, Pipe, Semicolon, and Tab.

  • If your CSV file contains headers, the header names are used as the XML tag names. The following characters aren't supported in XML tag names: ~, !, #, $, %, ^, &, *, +, `, |, :, \", \\, <, >, ?, ,, /. If your data source file contains any of these characters in a header name, use the data model editor Structure tab to edit the tag names.

  • CSV datasets support editing the data type assigned by the data model editor. See Edit the Data Type. If you update the data type for an element in the dataset, you must ensure that the data in the file is compliant with the data type that you selected.

  • The CSV files that you use as input to the Publisher data engine must be UTF-8 encoded and cannot contain empty column headers.

  • Group breaks, data links, expression and group-level functions aren't supported.

  • Data fields in CSV files must use the canonical ISO date format for mapped date elements, for example, 2012-01-01T10:30:00-07:00, and ######.## for mapped number elements.

  • CSV files aren't validated.

Create a Dataset from a Centrally Stored CSV File

You can use a CSV file from a file directory to create a dataset.

  1. On the data model editor toolbar, click New Dataset and select CSV File. The New Dataset - CSV File dialog launches.
  2. Enter a name for this dataset.
  3. Click Shared to enable the Data Source list.
  4. Select the Data Source where the CSV file resides.
    The list is populated from the configured File Data Source connections.
  5. Click Browse to connect to the data source, browse the available directories, and select the file.
  6. Select The first row a column header to specify if the first row in the file contains column names.
    If you do not select this option, the columns are assigned a generic name, for example, Column1, Column2. You can edit the XML tag names and display names in the data model editor Structure tab.
  7. Select the CSV delimiter used in the file.
    The default selection is Comma (,).
  8. Click OK.

Upload a CSV File Stored Locally

Create datasets using CSV files stored in local file directories.

To create a dataset using a CSV file stored locally:

  1. On the toolbar, click New Dataset and select CSV File. The New Dataset - CSV File dialog launches, as shown below.
  2. Enter a name for this dataset.
  3. Select Local to enable the Upload button.
  4. Click Upload to browse for and upload the CSV file from a local directory.
  5. Optional: Select The first row a column header to specify if the first row in the file contains column names. If you don't select this option, the columns are assigned a generic name, for example, Column1, Column2. The XML tag names and display names assigned can be edited in the data model editor Structure tab.
  6. Select the CSV Delimiter used in the file. The default selection is Comma (,).
  7. Click OK.

Edit the Data Type

After uploading a CSV file data type, you can edit it as needed.

To edit the data type for a CSV file element, click the data type icon or update it from the element Properties dialog.

The data for an element must be compliant with the data type that you assign. The user interface doesn't validate the data when you update the data type. If the data doesn't match, for example, a string value is present for an element you defined as Integer, errors may occur in the layout editing tools and or at runtime.

You can only update the data types for CSV file data sources.

Refresh and Delete an Uploaded CSV File

You can refresh and delete uploaded local CSV files.

After uploading the file, it is displayed on the Properties pane of the data model under the Attachments region, as shown below.

To refresh the local file in the data model:

  1. In the component pane, click Data Model to view the Properties page.

  2. In the Attachment region of the page, locate the file in the Data Files list.

  3. Click Refresh.

  4. In the Upload dialog, browse for and upload the latest version of the file. The file must have the same name or it won't replace the older version.

  5. Save the data model.

To delete the local file:

  1. In the component pane, click Data Model to view the Properties page.
  2. In the Attachment region of the page, locate the file in the Data Files list.
  3. Click Delete.
  4. Click OK to confirm.
  5. Save the data model.