The PSV Connector can convert Pipe-Separated Values (PSV) files into XML and also generate PSV files from XML.
XML is the primary format that ArcESB uses to manipulate data within a flow. Thus it is useful to convert PSV files into XML as a staging step for further processing within the flow, or to convert XML to a PSV file after the XML has been manipulated. Both of these operations can be accomplished with the PSV 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 PSV 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 PSV file when converting to XML. Please see Converting PSV 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 Subfolder Scheme Instructs the connector to group files in the Logs folder according to the selected interval. For example, the Weekly option instructs the connector to create a new subfolder each week and store all logs for the week in that folder. The blank setting tells the connector to save all logs directly in the Logs folder. For connectors that process many transactions, using subfolders can help keep logs organized and improve performance.
- 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 for specific use cases.
- Other Settings Allows configuration of hidden connector settings in a semicolon-separated list, like
setting1=value1;setting2=value2. Normal connector use cases and functionality should not require use of these settings.
Settings related to the automatic processing of files by the connector.
- Send Whether messages arriving at the connector will automatically be processed.
Converting PSV to XML
When a PSV 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 PSV 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 PSV
To convert XML to a PSV 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 PSV 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.
PSV Transformation: Using the XML Map Connector
Many data transformation flows use the PSV Connector in conjunction with the XML Map Connector.
Often, data enters an Arc flow in PSV 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 PSV Connector is commonly adjacent to an XML Map Connector in the flow:
When PSV files are the input to the flow, the PSV Connector converts a PSV file to XML and then passes that XML off to the XML Map Connector to be transformed; when PSV files are the output from the flow, the PSV Connector receives XML from the XML Map Connector and converts it into a PSV file.
The PSV Connector includes an Upload Test File feature to simplify the process of mapping the XML that represents a PSV 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 PSV Connector to generate a Source or Destination XML template.
In the Input tab of the PSV Connector, the More dropdown button includes the Upload Test File option. Select this option and browse to a sample PSV 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 PSV 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 PSV Connector is before the XML Map Connector in the flow) or a Destination File (if the PSV 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 PSV files processed by the PSV 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 PSV Connectors and multiple XML Map Connectors to handle distinct PSV structures.