Skip to main content

Flat (ascii) Files

The flat file type (.flat) is used with ASCII files (.asc) which contain fixed-length fields and optional line ends to mark the end of records. The actual ASCII data does not contain any information about the structure of fields or the data types of those fields. For information on data types, go to Data Types.

Read and Write Flat Files

Use an Input Data tool and Output Data tool to read and write .flat files. If you are reading an unknown file type into Designer and have selected the Read it as a fixed width text file option, see Flat File Layout.

Flat File Structure

The .flat file is written in XML and can be modified to describe information about the structure and data types of fields. The root element is flatfile with a version attribute, which must be set to 1. The flatfile element contains these child elements:

  • file: Declares where the actual flat-ASCII data is located and what kind of properties it has. The file has these attributes:

    • path: The path to the data file. It can be absolute or relative to the description file.

    • eoltype: The kind of line ends that you want to use. Valid options are none, crlf(default is Windows), lf(Unix), and cr(Mac).

    • allowShortLines: Indicates if a record can end before all fields are read. This is valid only for data with line ends. Missing fields will be set to Null. Valid options are true (t) or false (f) (default).

    • allowLongLines: Indicates if there can be extra characters after the last field for the current record. This extra data will be discarded. Valid options are true (t) or false (f)(default).

    • trimWhiteSpace: When this is true, blank characters are trimmed from field data. Valid options are true (t) or false (f).

  • fields: Contains one or many field elements. It has these attributes:

    • type: The data type of field. Valid types for flat files are Bool, Byte, Int16, Int32, Int64, FixedDecimal, Float, String, and V_String.

    • Byte is an unsigned number between 0 and 255, so the size of the byte is 3 characters. See Data Types for descriptions and examples of these types.

    • name: The name of the field.

    • length: The length of the field.

    • scale: Only used if the field type is FixedDecimal. In that case, this attribute is required.


<flatfile version="1">
    <field name="KEY " type="String" length="5" />
    <field name="NAME" type="String" length="12" />
    <field name="VALUE" type="Double" length="20" />