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 CData Arc uses to manipulate data within a flow. Therefore, it is useful to convert PSV files into XML as a staging step for further processing in 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 connector Id and description.
- Connector Id The static, unique identifier for the connector.
- Connector Type Displays the connector name and a description of what it does.
- Connector Description An optional field to provide a free-form description of the connector and its role in the flow.
Settings related to the core operation of the connector.
- Column headers present 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. You can use the following macros:
%ConnectorID%, %FilenameNoExt%, %RegexFilename:%, and %Header:%.
See Converting PSV to XML for more details.
Settings not included in the previous categories.
- Local File Scheme A scheme for assigning filenames to messages that are output by the connector. You can use the following macros to reference contextual information:
%ConnectorId%, %Filename%, %FilenameNoExt%, %Ext%, %ShortDate%, %LongDate%, %RegexFilename%, %DateFormat%, %Header%.
For example: %FilenameNoExt%_%ShortDate%%Ext%
- Processing Delay The amount of time (in seconds) by which the processing of files placed in the Input folder is delayed. This is a legacy setting. Best practice is to use a File connector to manage local file systems instead of this setting.
- Save to Sent Folder Check this to copy files processed by the connector to the Sent folder for the connector.
- Sent Folder Scheme Instructs the connector to group messages in the Sent folder according to the selected interval. For example, the Weekly option instructs the connector to create a new subfolder each week and store all messages for the week in that folder. The blank setting tells the connector to save all messages directly in the Sent folder. For connectors that process many messages, using subfolders helps keep messsages organized and improves performance.
- Log Level The verbosity of logs generated by the connector. When you request support, set this to Debug.
- 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 helps keep logs organized and improves performance.
- Log Messages Check this to have the log entry for a processed file include a copy of the file itself. If you disable this, you might not be able to download a copy of the file from the Input or Output tabs.
Miscellaneous settings are for specific use cases.
- Other Settings Enables you to configure hidden connector settings in a semicolon-separated list (for example,
setting1=value1;setting2=value2). Normal connector use cases and functionality should not require the use of these settings.
Settings related to the automatic processing of files by the connector.
- Send Whether messages arriving at the connector are automatically processed.
Settings related to the allocation of resources to the connector.
- Max Workers The maximum number of worker threads consumed from the threadpool to process files on this connector. If set, this overrides the default setting on the Settings > Automation page.
- Max Files The maximum number of files sent by each thread assigned to the connector. If set, this overrides the default setting on the Settings > Automation page.
Converting PSV to XML
When a PSV file is transformed into XML, the resulting XML has the following structure:
<Items> <Record> <field_0></field_0> <field_1></field_1> <field_2></field_2> </Record> </Items>
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 option set in Connector Settings. 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 is parsed, and the parsed headers are used as the element names for the value elements (the children of the record elements). Otherwise, the value elements are given generic names such as field_0, field_1, and so on.
Converting XML to PSV
To convert XML to a PSV file, the input XML must have a ‘flat’ structure. This means that, disregarding the Items root element, the depth of the XML structure is two. For example:
<Items> <film> <title>Citizen Kane</title> <year>1941</year> <runtime>119</runtime> </film> <film> <title>Sharknado</title> <year>2013</year> <runtime>86</runtime> </film> </Items>
The XML is interpreted as follows:
- Children of the root element are treated as records (rows) in the resulting file
- Children of each record element are treated as the values in each row
If the First line is header information option is enabled, a header row is inserted into the resulting PSV file with the names of each value element to provide context to the values. In the example above, 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 (for example, a database insert, an EDI file, or an insert into a CRM or ERP data source), 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
Therefore, 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 mapping input/source and the mapping output/destination. The Upload Test File feature makes it easy to use the PSV connector to generate a Source or Destination XML template.
Navigate to the Input tab of the PSV connector, click the More button, and choose Upload Test File. Browse to a local PSV file 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 detects this internal XML model and uses 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: The structure of this test file should be representative of 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 your test file. You might need to set up multiple PSV connectors and multiple XML Map connectors to handle distinct PSV structures.