The TSV Connector can convert Tab-Separated Values (TSV) files into XML and also generate TSV files from XML.
XML is the primary format that ArcESB uses to manipulate data within a flow. Thus it is useful to convert TSV files into XML as a staging step for further processing within the flow, or to convert XML to a TSV file after the XML has been manipulated. Both of these operations can be accomplished with the TSV connector.
This section contains all of the configurable connector properties.
Settings related to the core operation of the connector.
- Connector Id The static name of the connector. All connector-specific files are held in a folder by the same name within the Data Directory.
- Connector Description An optional field to provide free-form description of the connector and its role in the flow.
- First line is header information Whether the TSV file contains a row of headers providing names or context to the values in the file.
- Record Name The name of elements representing a row in the TSV file when converting to XML. Please see Converting TSV to XML for more details.
Settings that determine the folder on disk that files will be processed from, and where they will be placed after processing.
- Input Folder (Send) The connector can process files placed in this folder. If Send Automation is enabled, the connector will automatically poll this location for files to process.
- Output Folder (Receive) After the connector finishes processing a file, the result will be placed in this folder. If the connector is connected to another connector in the flow, files will not remain here and will instead be passed along to the Input/Send folder for the connected connector.
- Processed Folder (Sent) After processing a file, the connector will place a copy of the processed file in this folder if Save to Sent Folder is enabled. This copy of the file will not be passed along to the next connector in the flow.
Settings not included in the previous categories.
- Log Messages Whether the log entry for a processed file will include a copy of the file itself.
- Save to Sent Folder Whether files processed by the connector should be copied to the Sent folder for the connector.
Settings related to the automatic processing of files by the connector.
- Send Whether messages arriving at the connector will automatically be processed.
Converting TSV to XML
When a TSV file is transformed into XML, the resulting XML has the following structure:
Each row (record) in the original file becomes a child of the root element ‘Items.’ The name of all record elements is determined by the Record Name setting option. Each record element then has child elements corresponding to the values in each row of the input file.
Some TSV files include a line of header information that provides context to the values in the file.
When the First line is header information setting is enabled, this header line will be parsed, and the parsed headers will be used as the element names for the value elements (the children of the record elements).
Otherwise, the value elements will be given generic names such as field_0, field_1, etc.
Converting XML to TSV
To convert XML to a TSV file, the input XML must have a ‘flat’ structure. This means that, disregarding the root element, the depth of the XML structure is 2. For example:
The XML will be interpreted as follows: Children of the root element will be treated as records (rows) within the resulting file, and children of each record element will be treated as the values in each row. If the First line is header information option is enabled, a header row will be inserted into the resulting TSV file with the names of each value element to provide context to the values. In the above example, this header row would consist of title, year, and runtime.
TSV Transformation: Using the XML Map Connector
Many data transformation flows use the TSV Connector in conjunction with the XML Map Connector.
Often, data enters an Arc flow in TSV format and should exit the flow in some other format (e.g. a database insert, an EDI file, an insert into a CRM or ERP data source, etc), or vice versa. Arc uses a single streamlined approach to these data transformation requirements:
- Model the input format as XML
- Model the output format as XML
- Use the XML Map Connector to map between the input XML and the output XML
Thus the TSV Connector is commonly adjacent to an XML Map Connector in the flow:
When TSV files are the input to the flow, the TSV Connector converts a TSV file to XML and then passes that XML off to the XML Map Connector to be transformed; when TSV files are the output from the flow, the TSV Connector receives XML from the XML Map Connector and converts it into a TSV file.
The TSV Connector includes an Upload Test File feature to simplify the process of mapping the XML that represents a TSV file.
Upload Test File
An XML Map Connector requires a sample XML structure for both the Source/Input for the mapping and the Destination/Output for the mapping. The Upload Test File feature makes it easy to use the TSV Connector to generate a Source or Destination XML template.
In the Input tab of the TSV Connector, the More dropdown button includes the Upload Test File option. Select this option and browse to a sample TSV file on disk to instruct the connector to generate an internal XML model of this sample file.
Then, when an XML Map Connector is connected to this TSV Connector in the flow (and the flow changes are saved), the XML Map Connector can detect this internal XML model and use it as a Source File (if the TSV Connector is before the XML Map Connector in the flow) or a Destination File (if the TSV Connector is after the XML Map Connector in the flow).
Note that the structure of this Test File should be representative of all future files. In other words, all of the TSV files processed by the TSV Connector (and then the XML Map Connector) should have the same columns as the selected Test File. It may be necessary to set up multiple TSV Connectors and multiple XML Map Connectors to handle distinct TSV structures.