Available in Community Designer

Short Description
FlatFileWriter Attributes
Best Practices
See also

Short Description

FlatFileWriter writes data to flat files. The output flat file can be in form of CSV (character separated values), fixed-length format or mixed-length format (combination of mixed-length and fixed-length formats).

The component supports partitioning, compression, writing to output port or to remote destination.

UniversalDataWriter is an alias for FlatFileWriter.

Component Data output Input ports Output ports Transformation Transf. required Java CTL Auto-propagated metadata
FlatFileWriterflat file10-1



Port typeNumberRequiredDescriptionMetadata
for received data records any
for port writing. See Writing to Output Port. include specific byte/ cbyte/ string field


FlatFileWriter does not propagate metadata.

The component has no metadata template.

FlatFileWriter requires string, byte or cbyte field in the output metadata.

FlatFileWriter Attributes

AttributeReqDescriptionPossible values
File URL
where the received data to be written (flat file, output port, dictionary) are specified, see Supported File URL Formats for Writers.  

Character encoding of records written to the output.

The default encoding depends on DEFAULT_CHARSET_DECODER in defaultProperties.

ISO-8859-1 | UTF-8 | <other encodings>

If records are printed into an existing non-empty file, they replace the older ones by default (false).

If set to true, new records are appended to the end of the existing output file(s) content.

Some remote locations or compressed files do not support appending. See Appending to Files.

false (default) | true
Quoted strings When switched to true, all field values (except from byte and cbyte) will be quoted. If you do not set this attribute, its value is inherited from metadata on the input port (and displayed in faded grey text, see also Record Details). false | true
Quote character Specifies which kind of quotes will enclose output fields. Applies only if Quoted strings is true. By default, the value of this attribute is inherited from metadata on input port. See also Record Details. " | '
Create directories if set to true, non-existing directories in the File URL attribute path are created false (default) | true
Write field names Field labels are not written to output file(s) by default. If set to true, labels of individual fields are printed to the output. Please note that field labels differ from field names: labels can be duplicate and you can use any character in them (e.g. accents, diacritics). See Record Pane. false (default) | true
Records per file A maximum number of records to be written to each output file. If specified, the dollar sign(s) $ (number of digits placeholder) must be a part of the file name mask, see Supported File URL Formats for Writers1 - N
Bytes per file A maximum size of each output file in bytes. If specified, the dollar sign(s) $ (number of digits placeholder) must be a part of the file name mask, see Supported File URL Formats for Writers To avoid splitting a record into two files, the maximum size can be slightly overreached. 1 - N
Number of skipped records How many records/rows to be skipped before writing the first record to the output file, see Selecting Output Records. 0 (default) - N
Max number of records  How many records/rows to be written to all output files, see Selecting Output Records. 0-N
Exclude fields  A Sequence of field names separated by a semicolon that will not be written to the output. Can be used when the same fields serve as a part of Partition key.  
Partition key [ 1] A sequence of field names separated by a semicolon defining the records distribution into different output files - records with the same Partition key are written to the same output file. According to the selected Partition file tag, use a proper placeholder ($ or #) in the file name mask, see Partitioning Output into Different Output Files  
Partition lookup table[ 2] An ID of a lookup table serving for selecting records that should be written to output file(s). For more information, see Partitioning Output into Different Output Files.  
Partition file tag[ 1] By default, output files are numbered. If the attribute is set to Key file tag, output files are named according to the values of Partition key or Partition output fields. For more information, see Partitioning Output into Different Output Files. Number file tag (default) | Key file tag
Partition output fields[ 2] Fields of Partition lookup table whose values serve to name output file(s). For more information, see Partitioning Output into Different Output Files.  
Partition unassigned file name The name of a file into which unassigned records should be written, if there are any. If not specified, data records whose key values are not contained in Partition lookup table are discarded. For more information, see Partitioning Output into Different Output Files. 
Sorted input  If partitioning into multiple output files is turned on, all output files are open at once. This can lead to undesirable memory footprint for many output files (thousands). Moreover, for example unix-based OS usually have very strict limitation of the number of simultaneously open files (1024) per process. In case you run into one of these limitations, consider sorting the data according to a partition key using one of our standard sorting components and set this attribute to true. The partitioning algorithm does not need to keep open all output files, just the last one is open at one time. For more information, see Partitioning Output into Different Output Files. false (default) | true
Create empty files If set to false, prevents the component from creating an empty output file when there are no input records.true (default) | false
Skip last record delimiter  If set to true, the last record delimiter in a file is not written. If set to false, the last record delimiter in a file is written. false (default) | true

[ 1] Either both or neither of these attributes must be specified

[ 2] Either both or neither of these attributes must be specified


The type of formatting is specified in metadata for the input port data flow.

Appending to Files

Appending to files is supported, if you write data to:

  • local files

  • local zipped files

  • remote files via smb protocol

Appending to files is not supported in, if you write data to:

  • local gzipped files

  • remote files via ftp protocol

  • remote files via webdav protocol

  • remote files via Amazon S3 protocol

  • remote files via hdfs protocol

Null Values

Empty strings and null values are written to a file as empty strings.

Notes and Limitations

Field Size Limitation

FlatFileWriter can write fields of a size up to 4kB.

  • To enable bigger fields to be written into a file, increase the DataFormatter.FIELD_BUFFER_LENGTH property, see Chapter 19, Engine Configuration. Increasing the size of this buffer does not cause any significant increase of the graph memory consumption.

  • Another way to solve the big-fields-to-be-written issue is the utilization of the Normalizer component that can split large fields into several records.

Maps and Lists

FlatFileWriter cannot write maps and lists. If you do not need a field with map or list datatype in the output file, you can omit it using Exclude fields attribute. If you need to write the content of the map or list field, convert the field into string using Reformat first.


Writing Records to File
Producing Quoted Strings
Writing Records Without Delimiters
Writing Fixed-Length Records to Output Port

Writing Records to File

Write records to a file objects.txt using FlatFileWriter. The input metadata fields are color, shape and material.


Use the File URL attribute to define a path to the file to be created.

File URL${DATAOUT_DIR}/objects.txt

An example of the output file, delimited input metadata:


The separators "|" depend on metadata on the input edge.

The example of output file, fixed input metadata:

grey           cylinder      steel
brown          cube          wood
transparent    sphere        glass

Producing Quoted Strings

Write data from the previous example to a file. Each field value has to be surrounded by a quote character ' (apostrophe).


Use the attributes File URL, Quoted strings and Quote character.

File URL${DATAOUT_DIR}/objects-in-quotes.txt
Quoted stringstrue
Quote character'

If a string to be quoted contains a quote character, the quote character in the string is doubled. E.g. o'clock is quoted as 'o''clock'.

Writing Records Without Delimiters

This example shows writing records without writing record delimiters.

You receive an output from XMLWriter in a streaming mode. The records have to be seamlessly written to the file. No delimiter should be written between the records.


The solution to the problem depends on metadata. The input metadata of FlatFileWriter must have no Record delimiter, no Default delimiter, and must use EOF as delimiter.

In FlatFileWriter, enter File URL.

The records will be written without delimiters as no delimiters are specified in metadata.

Writing Fixed-Length Records to Output Port

Write several fields of fixed-length metadata into one field of the output port (provided one input record creates one output record).


Make sure that input metadata has no record delimiter set. Select metadata on the input edge and open the Edit Metadata window. Select the first row in the Record pane of the editor and make sure that the Record delimiter property is empty.

Create metadata on the output edge with a single field.

Use the attributes File URL and Records per file.

File URLport:$0.field1:discrete
Records per file1

Best Practices

We recommend to explicitly specify encoding of the output file (with the Charset attribute). It ensures better portability of the graph across systems with different default encoding.

The recommended encoding is UTF-8.



Since release 4.1.0-M1, the last record delimiters in a file can be skipped.


FlatFileWriter is available since CloverETL 4.2.0-M1. In 4.2.0-M1, UniversalDataWriter was renamed to FlatFileWriter.

See also

Common Properties of Components
Specific Attribute Types
Common Properties of Writers
Writers Comparison