Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

The To File component is a destination component that writes incoming data to a file or multiple files as needed. It serves to expand on the File Writer component with additional configurations and settings.

This adapter can be easily modified to add additional functionality or to fulfil extra requirements.

Running the Component

Info

The below steps assume the correct user permissions are in place to read/write files.

Expand
titleSTEP 1: Import the To File component

Using the + Component button+COMPONENT, import the To File component.

Expand
titleSTEP 2: Setup the component configurations & in the quickstart guidecomponent card
Screen Shot 2024-08-02 at 2.56.33 PM.png

Any field Fields marked with red is an asterisk* are required, otherwise the default value inside the default values defined in config.json will take its place.

FIELD NAME

are used:

Field

DescriptionDEFAULT VALUE

Default Value

DestinationDirectory *

Defines The directory where the destination folder will be placed

[EMPTY]

OutputFileMask

Defines the name of the files as well as the extensionoutput file(s) will be stored. The adapter will attempt to create it if it does not exist.

-

OutputFileMask

The name and extension of the output files.

%Y (year), %m (month), %d (day), %H (hour), %M (minute), %S (second) and %f (millisecond)

output_%Y_%m_%d_%H_%M_%S.txt

OneFilePerMessage

Specifies whether each inbound message will have its own file.

false

OutputEncoding

Defines the The encoding that is used in the output file - if left empty, it will default to either .

If left blank, encoding will be updated to the default according to OS. See Supported File Encodings.

Western (Windows-1252) for Windows

Western (ISO-8859-1) or Western (Windows-1252) depending on the OS[EMPTY] for Linux/Mac OS X.

Escape8BitCharacters

Specifies whether to escape non-ASCII characters in outbound messages.

Ex. "é" would be sent as "\XE9\" (in Latin-1 or Windows-1252) or "\XC3\\XA9\" (in UTF-8).

false

UseTempFiles

Specifies whether to use temporary files while writing.

true

Quickstart

If you want one file for all messages

Screen Shot 2024-08-02 at 3.30.02 PM.pngImage Removed

If you want one file for all the messages that came in a second/minute/hour/day/month/year

You can remove the timestamp masks to match your needs here (S = seconds, M = minutes and so on…)

Screen Shot 2024-08-02 at 3.33.08 PM.pngImage Removed

If you want one file for every message

Timestamp masks still get their values replaced with the current time but will not save multiple messages in one file.

Screen Shot 2024-08-02 at 3.34.30 PM.pngImage Removed

When true, it will append “.tmp” to files currently being written until the component is done writing to them. It will only remove the .tmp extension when a new file is written in.

true

Expand
titleSTEP 3: Start the component and verify the files from your destination directory

Start the component.

Once messages arrive to the componentinbound messages are processed, check the defined destination directory to see your newly created file(s).

Additional Details

...

Example Configurations

This is the format for the name that the resulting files will take. For instance, the value of the field being “output.txt”
Expand
Expand
titleOutputFileMask:
titleDestinationDirectory:

Is the directory where the file(s) will be stored. The adapter will attempt to create it if it does not exist.

Example 1 - If you want one file for all messages

If you want one file for all messages:

  • Set OneFilePerMessage to false

  • This will result in a single “output.txt“ file

that all the incoming data will go to.

While the value “output_%Y_%m_%d_%H_%M_%S.txt” will have masks replaced with timestamps as follows:

  • %Y: Year

  • %m: Month

  • %d: Day

  • %H: Hour

  • %M: Minute

  • %S: Second

  • %f: Millisecond

This OutputFileMask value will result in multiple files being created depending on when the data arrived. For example, if 2 bits of data arrived at 2024/12/30 at 16:45:55. They will be written to the same exact same file with the name “output_2024_12_30_16_45_55.txt” (unless the OneFilePerMessage field is set to true). If another bit came a second later, it will create a new file “output_2024_12_30_16_45_56.txt” and so on. You can add and remove masks as you please, but the smallest unit will determine how often a new file is created/a roll-over happens. So essentially, you can organize the data by the second/minute/hour/day/month/year (or millisecond) they arrived in.

Expand
titleOneFilePerMessage
This field is only used if you would like to put every single message that came in into its own file. If the OutputFileMask is “output.txt” then the files generated will be
  • containing all messages.

Screen Shot 2024-08-12 at 2.28.27 PM.pngImage Added

The OutputFileMask will behave differently depending if OneFilePerMessage is set to true:

  • OneFilePerMessage set to false will result in a single file “output.txt“ that all the incoming data will be written to.

  • OneFilePerMessage set to true will result in individual files generated as output.txt, output(1).txt, output(2).txt and so

on…Similarly, it does support the time masks, so assuming the OutputFileMask is
  • on. Similarly, with a timestamp mask “output_%Y_%m_%d_%H_%M_%S.txt”

and
  • , if two messages come in at the same time then the name of the files will be: “output_2024_12_30_16_45_55.txt” and “output_2024_12_30_16_45_55(1).txt”

...

8-Bit Unicode

...

Expand
titleOutputEncoding:

Used to indicate the type of encoding that you would like your data to be converted to (from UTF-8 by default), list of available encoding to convert can be found below.

Expand
titleUseTempFiles:

When set to true, it will append “.tmp” to files currently being written until the component is done writing to them. It will only remove the .tmp extension when a new file is written in.

Expand
titleEscape8BitCharacters:

When writing messages out, non-ASCII characters, like accented characters, can be escaped. E.g., "é" would be sent as "\XE9\" (in Latin-1 or Windows-1252) or "\XC3\\XA9\" (in UTF-8).

Supported Encodings

...

Encoding Name

...

Code

...

Chinese (Big 5 HKSCS)

...

BIG5-HKSCS

...

Chinese (GB 18030)

...

GB18030

...

Chinese (GB 2312)

...

GB2312

...

Chinese (GBK)

...

GBK

...

Japanese (ISO-2022-JP)

...

ISO-2022-JP

...

Korean (ISO-2022-KR)

...

ISO-2022-KR

...

Western (ISO-8859-1)

...

ISO-8859-1

...

Central European (ISO-8859-2)

...

ISO-8859-2

...

South European (ISO-8859-3)

...

ISO-8859-3

...

Central European (ISO-8859-4)

...

ISO-8859-4

...

Cyrillic (ISO-8859-5)

...

ISO-8859-5

...

Arabic (ISO-8859-6)

...

ISO-8859-6

...

Greek (ISO-8859-7)

...

ISO-8859-7

...

Hebrew (ISO-8859-8)

...

ISO-8859-8

...

Turkish (ISO-8859-9)

...

ISO-8859-9

...

Western (Windows-1252)

...

Windows-1252

...

Chinese (Big 5)

...

big5

...

Japanese (EUC-JP)

...

eucJP

...

Japanese (Shift JIS)

...

sjis

Example 2 - If you want one file for every message

If you want one file for every message:

  • Set OnFilePerMessage to true

  • Using the default OutputFileMask, the timestamp will be updated with the current time, each time a message is written to the file.

Screen Shot 2024-08-12 at 2.31.28 PM.pngImage Added
Expand
titleExample 3 - If you want one file for all the messages that came in the same second/minute/hour/day/month/year

If you want one file for all the messages that came in the same second/minute/hour/day/month/year:

  • Set OneFilePerMessage to false

  • Messages will be written to files according to the OutputFileMask timestamp specified.

Screen Shot 2024-08-12 at 2.31.10 PM.pngImage Added

The OutputFileMask is both the format of the outbound file names as well as can be used to determine when a new file is created.

You can modify a mask as required, but the smallest unit will determine how often a new file is created/a roll-over happens. This allows you to organize data by the second/minute/hour/day/month/year (or millisecond) it arrived in.

  • If 2 bits of data arrived at 2024/12/30 at 16:45:55, they will be written to the same file with the name “output_2024_12_30_16_45_55.txt” (unless the OneFilePerMessage field is set to true).

  • If another bit came a second later, it will create a new file “output_2024_12_30_16_45_56.txt” and so on.