# tHConvertFile properties for Apache Spark Batch

These properties are used to configure tHConvertFile running in the Spark Batch Job framework.

The Spark Batch tHConvertFile component belongs to the Processing family.

This component is available in Talend Platform products with Big Data and in Talend Data Fabric.

## Basic settings

| Storage | To connect to an HDFS installation, select the Define a storage configuration component<br>check box and then select the name of the component to use from those<br>available in the drop-down list.<br><br>This option requires you to have previously configured the<br>connection to the HDFS installation to be used, as described in the<br>documentation for the tHDFSConfiguration component.<br><br>If you leave the Define a<br>storage configuration component check box unselected,<br>you can only convert files locally. |
| --- | --- |
| Configure Component | To configure the component, click the [...] button and, in the Component Configuration window, perform<br>the following actions.<br><br><ol> <li> <p>Click the <span>Select</span> button next to the <span>Record structure</span> field and then,                                    in the <span>Select a Structure</span>                                    dialog box that opens, select the structure you want to use when                                    converting your file and then click <span>OK</span>.</p> <p>This structure must have been previously created                                    in <em> <span>Talend Data Mapper</span> </em>.</p> </li> <li> <p>Select the <span>Input                                        Representation</span> to use from the drop-down                                    list.</p> <p>Supported input formats are Avro, COBOL, EDI,                                    Flat, IDocs, JSON and XML.</p> </li> <li> <p>Select the <span>Output                                        Representation</span> to use from the drop-down list.                                    The choices available for the Output representation depend on                                    what you choose for the Input representation.</p> <p>Supported output formats are Avro, Flat, JSON and                                    XML.</p> </li> <li> <p>Click <span>Next</span>.</p> </li> <li> <p>Tell the component where each new record begins.                                    In order for you to be able to do so, you need to fully                                    understand the structure of your data.</p> <p>Exactly how you do this varies depending on the                                    input representation being used, and you will be presented with                                    one of the following options.</p> <ol> <li> <div>Select an appropriate record delimiter                                            for your data. Note that you must specify this value                                            without quotes.<ul> <li> <p> <span>Separator</span>                                                  lets you specify a separator indicator, such as <em>\n</em>, to identify a new                                                  line.</p> <p>Supported indicators are <em>\n</em> for a Unix-type new line,                                                  <em>\r\n</em> for Windows and <em>\r</em> for Mac, and <em>\t</em> for tab characters.</p> </li> <li> <p> <span>Start/End                                                  with</span> lets you specify the initial                                                  characters that indicate a new record, such as <em>&lt;root</em>, or the characters                                                  that indicate where a record ends. This can also                                                  be a regular expression.</p> <p> <span>Start with</span>                                                  also supports new lines, <em>\n</em>                                                  for a Unix-type new line, <em>\r\n</em> for Windows and <em>\r</em> for Mac, and <em>\t</em> for                                                  tab characters.</p> </li> <li> <span>Sample File</span>: To test the                                                  signature with a sample file, click the                                                  <span>[...]</span> button, browse to the                                                  file you want to use as a sample, click                                                  <span>Open</span>, and then click                                                  <span>Run</span> to test your                                                  sample.<p>Testing the signature lets you check                                                  that the total number of records and their minimum                                                  and maximum length corresponds to what you expect                                                  based on your knowledge of the data. This step                                                  assumes you have a local subset of your data to                                                  use as a sample.</p> </li> </ul> <ul> <li> <p>Click <span>Finish</span>. </p> </li> </ul> </div> </li> <li> <div>If your input                                            representation is COBOL or Flat with positional and/or                                            binary encoding properties, define the signature for the                                            input record structure:<ul> <li> <span>Input Record                                                  root</span> corresponds to the root element                                                  in your input record.</li> <li> <p> <span>Minimum Record                                                  Size</span> corresponds to the size in bytes                                                  of the smallest record. If you set this value too                                                  low, you may encounter performance issues, since                                                  the component will perform more checks than                                                  necessary when looking for a new record.</p> </li> <li> <p> <span>Maximum Record                                                  Size</span> corresponds to the size in bytes                                                  of the largest record, and is used to determine                                                  how much memory is allocated to read the                                                  input.</p> </li> <li> <span>Maximum Block Size                                                  (BLKSIZE)</span> correspond to the size in                                                  bytes of the largest block in Variable Blocked                                                  files. If you do not have the exact value, you can                                                  enter <kbd>32760</kbd>, which is the                                                  maximum BLKSIZE.<p>With the Variable Blocked                                                  signature, each block is extracted as the Spark                                                  record. Each map execution processes an entire                                                  block and not an individual Cobol record, as with                                                  other Cobol signatures.</p> </li> <li> <span>Sample from                                                  Workspace</span> or <span>Sample from File                                                  System</span>: To test the signature with a                                                  sample file, click the <span>[...]</span> button, and then                                                  browse to the file you want to use as a sample.<p>Testing the signature lets you                                                  check that the total number of records and their                                                  minimum and maximum length corresponds to what you                                                  expect based on your knowledge of the data. This                                                  step assumes you have a local subset of your data                                                  to use as a sample.</p> </li> <li> <p> <span>Footer                                                  Size</span> corresponds to the size in bytes                                                  of the footer, if any. At runtime, the footer will                                                  be ignored rather than being mistakenly included                                                  in the last record. Leave this field empty if                                                  there is no footer.</p> </li> <li> <p>Click the                                                  <span>Next</span> button to open the <span>Signature                                                  Parameters</span> window, select the fields                                                  that define the signature of your record input                                                  structure (that is, to identify where a new record                                                  begins), update the <span>Operation</span> and                                                  <span>Value</span> columns as appropriate, and                                                  then click <span>Next</span>.</p> </li> <li> <p>In the <span>Record Signature                                                  Test</span> window that opens, check that your                                                  Records are correctly delineated by scrolling                                                  through them with the <span>Back</span> and <span>Next</span> buttons and performing a visual                                                  check, and then click <span>Finish</span>.</p> </li> </ul> </div> </li> </ol> </li> </ol> |
| Input | Click the [...]<br>button to define the path to where the input file is stored.<br><br>You can also enter the path manually, between quotes. |
| Output | Click the [...]<br>button to define the path to where the output file will be stored.<br><br>You can also enter the path manually, between quotes. |
| Action | From the drop-down list, select:<br><br><ul> <li> <p> <span>Create</span> if you want                                        the conversion process to create a new file.</p> </li> <li> <p> <span>Overwrite</span> if you want                                        the conversion process to overwrite an existing file.</p> </li> </ul> |
| Open Structure Editor | Click the [...]<br>button to open the structure for editing in the Structure Editor of *Talend Data Mapper*.<br><br>For more information, see *Talend Data Mapper User Guide*. |
| Merge result to single<br>file | By default, the tHConvertFile creates several part files. Select this<br>check box to merge these files into a single file.<br><br>Information noteNote: This option is available only if you have installed the<br>R2020-07 Studio Monthly update or a later one delivered by Talend. For more information, check with<br>your administrator.<br><br>The following options are used to manage the source and<br>the target files:<br><br><ul> <li> <span>Merge File                            Path</span>: enter the path to the file which will                            contain the merged content from all parts.</li> <li> <span>Remove source                                        dir</span>: select this check box to remove the source                                    files after the merge.                            </li> <li> <span>Override target file</span>: select                                    this check box to override the file already existing in the                                    target location. This option does not override the folder.                            </li> <li> <span>Include                            Header</span>: select this check box to add the CSV                            header to the beginning of the merged file. This option is only                            used for CSV outputs. For other representations, it has no                            effect on the target file.</li> </ul><br><br>Information noteWarning: Using this option with an Avro output creates an<br>invalid Avro file. Since each part starts with an Avro Schema header,<br>the merged file would have more than one Avro Schema, which is<br>invalid. |

## Advanced settings

| Die on error | Select the check box to stop the execution of the Job when an error occurs.<br><br>Clear the check box to skip any error and continue the Job execution process. |
| --- | --- |

## Usage

| Usage rule | This component is used with a tHDFSConfiguration component which defines the<br>connection to the HDFS storage, or as a standalone component for<br>converting local files only. |
| --- | --- |
| Usage with Talend Runtime | If you want to deploy a Job or Route containing a data mapping component<br>with Talend Runtime, you first need to install the Talend Data Mapper feature. For more information, see [Using Talend Data Mapper with Talend Runtime](https://help.qlik.com/talend/r/en-US/7.3/data-mapper-user-guide/using-talend-data-mapper-with-talend-runtime). |