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 nor the data types of those fields. For information on data types, see 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
flatfile element contains the following 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
crlf(default is Windows),
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
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
trimWhiteSpace: When this is true, blank characters are trimmed from field data. Valid options are
fields: Contains one or many field elements. It has the following 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" />