Function Name |
Text File Data Target | ||||||||
Category |
Text | ||||||||
Icon |
|||||||||
Description |
Writes data from to a delimitated or fixed width format file (CSV etc). | ||||||||
Inputs |
|
||||||||
Outputs |
|
||||||||
Properties |
|
When the Text Writer component is dragged onto a transform a setup wizard is launched to guide you through the creation of the data target.
If you already have an example of an output file then you can use this to define the structure that will be used for your writer.
The "Read structure from existing sample document" runs another wizard that allows you to define the structure of your document based on an existing file format.
There are 2 forms of file delimited and fixed width, delimited files use a special character to separate fields, fixed width pad all the fields so they take up the same amount of space.
Some files also contain the column names on the first row.
Select the options that are applicable and press Next.
If your file was delimitated, then the next screen allows you to define the rules used to read each field.
The delimiters break the fields, it's possible to select a number of delimiters, but in practice the file normally only uses a tab or a comma.
The "Fields are enclosed in quotes" property means that if the first char within a field is a quote then the value is considered to be everything up to the next quote. This makes it possible for a field to contain the delimiter character. If the field also needs to contain a quote char then 2 quote chars in a row are interpreted as a single quote.
Data | Field 1 Value | Field 3 Value | Field 3 Value | Field 4 Value |
---|---|---|---|---|
abc,123,xyz | abc | 123 | xyz | |
abc,"123",xyz | abc | 123 | xyz | |
abc,"1,23",xyz | abc | 1,23 | xyz | |
abc,1,23,xyz | abc | 1 | 2 | xyz |
abc,"1""23",xyz | abc | 1"23 | xyz | |
abc,"1"23",xyz | ERROR | |||
abc,1"23,xyz | abc | 1"23 | xyz | |
abc,"1""2,3",xyz | abc | 1"2,3 | xyz |
If your source data contained column headings then you may well be finished at this stage, however if the data contains no column information, or you don't like the names in the file then you can change them on this page.
Simply select the column to edit and set the name (if you are working on a fixed width file then you also get the option to set the column width).
The default filename that will be used to write out the new text file. If this is not specified then the input connection point 'Filename' must be connected.
This provides a simple way to write to a single file, if you need to create multiple files or construct the filename dynamically, then leave this blank.
Once you press Finish the new Text Data target is added to the transform and can be used as any other data target is.
The name of the component, must be unique within the transform
Allows the column definitions to be manually edited.
If the writer component does not have a connector to the 'Filename' input then the filename the data is written to is taken from this property.
If the connection point 'Filename' is connected, then this property is ignored (and can be blank)
Indicates that the filename is to be resolved relative to the data mapping file (.dm). If the transform is compiled the filename will be resolved relative to the compiled exe.
The encoding used to write the text data to a file.
If checked then all the column headings are written onto the first line of the file.
The component has a root input called 'Filename', each value provided to this is treated as a filename and a new Text document is created.
If the 'Filename' input (and the 'Data' Output) is not connected then the "Default Target Uri" is used (see properties window).
The child inputs are all specific to the Text standard you selected when the component was created.
The Data output returns the resulting Text document as a string. This allows it to be consumed by other components rather than just being written to a file.
If the Data output is connected the Default Target Uri property is ignored.
It is an error to have connections to BOTH the Data output and the Filename input.