# File Input

The FileInput component is used to load data from files, and it can parse the contents of the file against a predefined data structure. This helps to ensure that the data being loaded is in the correct format and meets the required criteria before further processing is carried out.&#x20;

<img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image228.png" alt="" data-size="line">

## **Input**

&#x20;

<table><thead><tr><th width="196">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>Input Path</td><td>Input directory</td></tr><tr><td>Input File</td><td>Input file. File name can contain wild card (*).</td></tr><tr><td>Suffix Allowed</td><td><p>Extension list delimited with comma(,). </p><p>ex) *.txt, .dat ??? files with txt extension or dat extension will be loaded.</p><p>(*) Input File and Suffix Allowed are not mutual exclusive. Files which match either conditions are loaded.</p></td></tr><tr><td>Wait Seconds</td><td>Wait time in seconds until the file is not modified. Default seconds is 5 seconds.</td></tr><tr><td>Contents Type</td><td><p>The type of loaded contents.</p><p>·       Byte array</p><p>·       String</p><p>·       ISM data</p><p>The default option is byte array. If ISM data is chosen, the contents are parsed against the predefined data structure. And this data structure comes from the Output property</p></td></tr><tr><td>Ignore File Not Found</td><td><p>Action when the input file is not found.</p><p>·       Ignore</p><p>·       Throw error</p></td></tr><tr><td>After Get</td><td><p>Action after the input file(s) are loaded.</p><p>·       Do Nothing</p><p>·       Backup</p><p>·       Delete</p></td></tr><tr><td>Backup Path</td><td>Backup directory if the After Get action is backup.</td></tr></tbody></table>

&#x20;

## **Output**

&#x20;

<table><thead><tr><th width="214">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>FileContents</td><td>Contents of the input file(s). Contents are storead as byte array</td></tr><tr><td>DataStructureId</td><td>Data structure id for mapping</td></tr><tr><td>FileInfos</td><td>File list. This attribute contains java.io.File objects</td></tr><tr><td>UseMapping</td><td> </td></tr></tbody></table>

If Use in mapping is yes, remove the default value and set a different value.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image229.png" alt=""><figcaption></figcaption></figure>

&#x20;

## **Example**

&#x20;

### **File To DB**

In this scenario, a source file containing data needs to be synchronized with a target database table. The source file has six columns: id, birth date, first name, last name, gender, hire date, and the target table has the same columns.

The flow starts with the FileInput task, which reads the source file and passes the data to the Mapping component. The Mapping component is used to transform the data into a format that can be inserted into the target table. In this case, it simply maps the source columns to the target columns with the same name.

Next, the SQLBatch task is used to execute a batch insert statement to insert the transformed data into the target table.&#x20;

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image230.png" alt="" width="563"><figcaption></figcaption></figure>

If the input file has a header line, the first row of data may be treated as invalid data or it may cause the data to be incorrectly mapped to the output. Therefore, it is recommended to remove the header line before processing the input file.

#### File Input

<table data-header-hidden><thead><tr><th width="232"></th><th></th></tr></thead><tbody><tr><td>Attributes</td><td>Description</td></tr><tr><td>Input Path</td><td>Assign input directory</td></tr><tr><td>Input File</td><td>Assign file name ??? only one file is allowed</td></tr><tr><td>Suffix Allowed</td><td>-</td></tr><tr><td>Wait Seconds</td><td>1</td></tr><tr><td>Contents Type</td><td>Data</td></tr><tr><td>Ignore File Not Found</td><td>-</td></tr><tr><td>After Get</td><td>-</td></tr><tr><td>Backup Path</td><td>-</td></tr></tbody></table>

The input file is parsed against the data structure and stored in the parameter called MyEmployees. The parsed data is stored in a file backed list to avoid OutOfMemory issue.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image231.png" alt=""><figcaption></figcaption></figure>

#### Mapping

Mapping does simply connect the input fields to the correspondent output fields.&#x20;

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image232.png" alt=""><figcaption></figcaption></figure>

&#x20;

#### SQLBatchExecutor

SQLBatchExecutor gets input data from MappingResult.&#x20;

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image233.png" alt="" width="563"><figcaption></figcaption></figure>

·       Data structure

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image234.png" alt=""><figcaption></figcaption></figure>

·       Input file

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image235.png" alt="" width="375"><figcaption></figcaption></figure>

·       Target database

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image227.png" alt="" width="563"><figcaption></figcaption></figure>
