Write CSV File

Operation Name

Write CSV File

Function Overview

Write input data to a file of format such as CSV (Comma Separated Values), TSV (Tab Separated Values), etc.

Data Model

Table model type.

Properties

For details on use of variables, refer to “Variables”.
Basic settings
Item name Required/Optional Use of variables Description Remarks
Name Required Not available Enter the name to show on the script canvas.  
Input data Required Not available Select a component on the script canvas.  
Required settings
Item name Required/Optional Use of variables Description Remarks
File Required Available Enter the file path of CSV or TSV.

You can click [Browse] button to launch file chooser and find the file.
Delimiter mode Required Not available Select a method to specify delimiter.
  • [Select from list]: (default)
    Select a delimiter character from list.
  • [Enter directly]:
    Enter the delimiter character directly in the field.
  • [Enter character code]:
    Enter the delimiter character using character code in the field.
  • Depending on selected method, the corresponding input field is displayed.
Select from list/Delimiter Optional Not available Select a delimiter character.
  • [Comma]: (default)
    Specify comma (,).
  • [Tab]:
    Specify tab.
  • [Space]:
    Specify space ( ).
  • [Semicolon]:
    Specify semicolon (;).
  • [Slash]:
    Specify slash (/).
  • [Vertical bar]:
    Specify vertical bar (|).
  • Enabled when [Select from list] is selected in [Delimiter mode].
Enter directly/Delimiter Optional Available Enter one character for delimiter.
  • Enabled when [Enter directly] is selected in [Delimiter mode].
  • Double quotation cannot be specified in delimiter character.
Enter character code/Delimiter Optional Available Enter the character code.
The character code is converted with the encoding specified in [Encoding].

You can enter the code as octal (with prefix "0" <number 0>), decimal (without prefix), and hexadecimal (with prefix "0x" <alphabet x with numeric 0> or "#").
When padding is in multi-byte string, enter it by separating with comma. Example: 0x10,0x13
  • Enabled when [Enter character code] is selected in [Delimiter mode].
  • Character code that converts to one character can be entered.
  • Character code that converts to newline code or double quotation, cannot be specified.
Column list Optional - Specify columns.

Each column can be operated with the following buttons.
  • [Add]:
    Add a column.
  • [Up]:
    Move the selected column upwards by one row.
  • [Down]:
    Move the selected column downwards by one row.
  • [Delete]:
    Delete the column.
  • Data will be written only for the number of columns set in [Column list].
  • Column name set in [Column list] will be displayed in Mapper schema.
Column list/Column name Required Available Enter the column name.

The first row of the file specified in [File] can be set as column names using [Update column list] property action.
 
Column list/Quotation Optional Not available Select whether or not to enclose each column with double quotations.
  • [Checked]:
    Enclose column with double quotations.
  • [Not checked]: (default)
    Do not enclose column with double quotations.
 
Property actions
Item name Description Remarks
Preview When preview is clicked, the contents of the file specified in [File] is displayed.
  • Disabled when the specified file does not exist or variables are set in [File].
  • Displayed with the encoding specified in [Encoding].
  • File contents cannot be edited.
  • The maximum file size that can be displayed in the previewer is 1MB. When the file size exceeds 1MB, the file is displayed up to 1MB from the beginning of the file.
Update column list The first row of the file specified in [File] is set as column names.
  • Disabled when the specified file does not exist or variables are set in [File].
Read column names from first row of file Select the file in file chooser, and the first row of that file is set as column names.  
Read the number of columns from file Select the file in file chooser, and the number of columns of that file is set as the number of column names.  
Write settings
Item name Required/Optional Use of variables Description Remarks
Encoding Required Available Select or enter an encoding for the file.

When you enter encoding, specify one of the encodings supported in Java SE Runtime Environment 8.
For more details, refer to “Supported Encodings” (http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html).
Newline code Required Not available Select a newline code.
  • [AUTO]: (default)
    It will be the newline code of the OS in which DataSpiderServer operates.
    • Windows:
      CR+LF
    • UNIX/Linux:
      LF
  • [CR]:
  • [LF]:
  • [CR+LF]:
 
Overwrite Optional Not available Select whether or not to overwrite when the specified file exists.
  • [Checked]: (default)
    Overwrite.
  • [Not checked]:
    Do not overwrite. When the file already exists, an error occurs.
 
Append Optional Not available Select whether to append or overwrite the file when the specified file exists.
  • [Checked]:
    Append to the end of the file.
  • [Not Checked]: (default)
    Overwrite.
  • Enabled only when [Overwrite] is checked.
Insert column names into first row Optional Not available Select whether or not to insert column names into the first row of the specified file.
  • [Checked]:
    Insert [Column name] of [Column list] into the first row.
  • [Not Checked]: (default)
    Do not insert column names.
  • Column names will be inserted not in the first line of the file to be written to, but in the first row of the result data.
Do not insert column names when the file exists Optional Not available Select whether or not to insert column names in the first row of the result data when the specified file exists.
  • [Checked]:
    Do not insert column names in the first row of the result data when the specified file exists.
  • [Not checked]: (default)
    Insert column names in the first row of the result data.
  • Enabled when [Insert column names in first row] is checked.
Transaction
Item name Required/Optional Use of variables Description Remarks
Execute transaction processing Required Not available Select whether or not to execute transaction processing.
  • [Checked]:
    Transaction processing will be executed.
  • [Not checked]: (default)
    Transaction processing will not be executed.
Refer to “Transaction of file category adapters” for more details.
 
Comment
Item name Required/Optional Use of variables Description Remarks
Comment Required Not available You can write a short description of this adapter.
The description will be reflected in the specifications.
 

Schema

Input schema

The number of columns varies depending on the [Column list] settings.
Refer to “Schema of table model type” for more details.

Output schema

None.

Loading schema in Mapper

Schema is loaded automatically.
Refer to “Edit Schema” for more details.

Transaction

Transaction is supported.

Transaction is enabled only when [Execute transaction processing] of [Transaction] is checked.

PSP Usage

PSP is supported.
Refer to “Parallel Stream Processing” for more details.

Available Component Variables

Component variable name Description Remarks
count The number of written data is stored.
  • Default value is null.
message_category When an error occurs, the corresponding message code's category is stored.
  • Default value is null.
message_code When an error occurs, the corresponding message code is stored.
  • Default value is null.
message_level When an error occurs, the corresponding message code's severity is stored.
  • Default value is null.
error_type When an error occurs, the error type is stored.
  • Default value is null.
  • The error type will be in the following format.
    Example: “java.io.FileNotFoundException”
  • The contents that will be stored may vary depending on DataSpider Servista versions.
error_message When an error occurs, the error message is stored.
  • Default value is null.
  • The contents that will be stored may vary depending on DataSpider Servista versions.
error_trace When an error occurs, the error's trace information is stored.
  • Default value is null.
  • The contents that will be stored may vary depending on DataSpider Servista versions and client applications.

Specification Limits

Major Exceptions

Exception name Cause Solution
InputDataNotFoundException [Input data] is not specified. Specify [Input data] or draw data flow.
InvalidPropertyConfigurationException
<property name> is not specified.
[<property name>] is not specified. Specify [<property name>].
InvalidPropertyConfigurationException
Invalid delimiter is specified.
Invalid character is entered in [Delimiter]. Enter the valid character in [Delimiter].
FileIsDirectoryException The path entered in [File] is directory. Enter file path in [File].
FileAlreadyExistedException The specified file does not exist in [File]. Change the file name of [File], or check [Overwrite] of [Write settings].
FileIsLockedException The file specified in [File] is being locked. Unlock from Explorer or CLI.
java.io.FileNotFoundException
Some other process is using the file.
File specified in [File] is being used by some other process. Make sure that it is not being used by some other process.
java.io.UnsupportedEncodingException Unsupported encoding is specified in [Encoding]. Specify an encoding supported in Java SE Runtime Environment 8.
For more details, refer to “Supported Encodings” (http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html).

Notes