Why CSV Formats and CSV Fold cannot produce CRLF or pre-header title blocks alone
When you configure a custom CSV schema under Orchestration Settings -> CSV Formats (Create CSV Formats) and use it in a loop’s CSV Fold aggregation (Add Aggregations), Orchestration Builder lets you configure:
- Header Row (checkbox to include the column names as the first line)
- Separator Character (defaults to
,) - Escape Character (defaults to
\) - Quote Character (defaults to
") - Columns (column names and required flags)
However, third-party payroll, banking, and benefits vendors frequently enforce three file formatting rules that CSV Formats and CSV Fold do not expose directly:
- Windows
CR/LF(\r\n) line endings instead of the default UNIXLF(\n) line endings produced by CSV Fold and Create Text Template. - A static title or banner row above the CSV header row (for example,
PARTICIPANTSon line 1, followed byName,First Name,Last Name,Employee IDon line 2). - Skipping an arbitrary number of metadata/preamble lines (for example, the first 8 lines of an inbound bank rate CSV) before iterating over the data rows.
Here is how to implement all three patterns cleanly in Workday Orchestrate.
Pattern 1: Outputting Windows CR/LF (\r\n) line endings and a pre-header title row
When you type a normal multi-line template inside Create Text Template, Orchestration Builder emits a UNIX newline (\n) at the end of every line. If you simply place {{chars.cr}} at the end of each line, or let {{#each ...}} sit on its own line, your output file will contain extra blank lines or mixed \n and \r\n terminators.
The key is to combine Orchestrate’s built-in character references ({{chars.cr}}{{chars.newline}}) with the line continuation backslash (\) documented in Concept: Text Templates:
- Ending any template line with a single backslash (
\) tells Create Text Template to ignore both the backslash and the subsequent UNIX line break in the template editor. - Ending a line with
{{chars.cr}}{{chars.newline}}\therefore writes an exact Windows\r\nsequence and suppresses the template editor’s own\n.
Step-by-step configuration
- On your upstream Loop‘s CSV Fold aggregation (for example,
LoopBatchToCSVproducingCSVOutput), leave Header Row unchecked in the CSV Format if you plan to write the title line and column headers inside Create Text Template. - Add a Create Text Template step with Content Type set to
text/csv. - Enter the template below, ensuring there are no trailing spaces after the
\at the end of each line:
PARTICIPANTS{{chars.cr}}{{chars.newline}}\
Name,First Name,Last Name,Preferred Name,Job Profile,Effective Date,Employee ID{{chars.cr}}{{chars.newline}}\
{{#each data.LoopBatchToCSV.CSVOutput.iterator}}\
{{this}}{{chars.cr}}{{chars.newline}}\
{{/each}}How this template works
- **Line 1 (
PARTICIPANTS{{chars.cr}}{{chars.newline}}\):** Writes the vendor’s required pre-header title line terminated by\r\n, and suppresses the editor’s newline. - **Line 2 (
Name,First Name,...{{chars.cr}}{{chars.newline}}\):** Writes the CSV column header row terminated by\r\n. - **Line 3 (
{{#each data.LoopBatchToCSV.CSVOutput.iterator}}\):** Iterates over each aggregated CSV row (CsvRowconverted to string via{{this}}). The trailing\prevents the{{#each ...}}tag itself from injecting a blank line before the first data row. - **Line 4 (
{{this}}{{chars.cr}}{{chars.newline}}\):** Outputs the formatted CSV row followed by\r\n. Because **Create Text Template**’s runtime is fully streaming, iterating throughCSVOutput.iteratorstreams large CSV files to your downstream Store Document step without holding the concatenated string in memory.
If you only need to prepend a static title row above a CSV Fold output that already includes its own header row and uses standard UNIX \n line endings, you can pass the entire CSV output without looping:
PARTICIPANTS
{{data.LoopBatchToCSV.CSVOutput}}Pattern 2: Skipping the first N preamble lines when reading an inbound CSV
Inbound bank and treasury CSV files often begin with several non-tabular metadata rows before the actual data rows start. For example, consider a foreign-exchange rate file where data rows begin on line 9 (after 8 preamble and header lines):
Fixed Rates Customer: ,XXX,
Platform: ,Cashpro Payments,
Rate Convention: ,Market Convention,
Home Currency: ,USD,
Maximum Transaction Amount: ,1 USD,
,
Currency,Trade Amount <= 1 USD,Rate Direction
,Buy,
CAD,1.3585,Indirect
EUR,2.1789,Direct
GBP,3.37,DirectIf you pass .asCSV().iterator() or .asCSV().rows() into a Loop, Orchestrate starts reading at line 1 (row 0), which fails column parsing or pollutes your loop with metadata lines.
Using .rows(from: Number) on a Csv instance
Workday’s Reference: Csv Member Functions provides three overloads of the .rows member function on Csv objects:
| Member Function | Arguments | Behavior |
|---|---|---|
Member Functioncsv.rows() |
ArgumentsNone | BehaviorReturns a CsvRowIterator over all rows in the CSV (excluding the header row, if one is defined in the CsvFormat). |
Member Functioncsv.rows(from: Number) |
Argumentsfrom (0-indexed Number) |
BehaviorReturns a CsvRowIterator starting from the specified 0-indexed row number to the end of the file. |
Member Functioncsv.rows(from: Number, to: Number) |
Argumentsfrom (Number), to (Number) |
BehaviorReturns a CsvRowIterator starting at from and ending at to (both 0-indexed). |
Because .rows(from) is 0-indexed, rows 0 through 7 represent the first 8 lines of the file, and index 8 is the 9th line (CAD,1.3585,Indirect).
In your Loop step’s Data Set expression field, treat the inbound document as CSV (with a CSV Format where Header Row is unchecked) and call .rows(8):
data.RetrieveRateFile.document.asCSV("UnheadedThreeColumnFormat").rows(8)Inside the loop, read each column by 0-based index (data.LoopRates.item.columnValueAtIndex(0) for "CAD", data.LoopRates.item.columnValueAtIndex(1) for "1.3585") or by column name (data.LoopRates.item.columnValue("Currency")) defined on UnheadedThreeColumnFormat.
How to verify your CSV output and row skipping in the tenant
- For outbound
CR/LFfiles, run the orchestration, download the stored CSV file from the Integration Event‘s Documents tab, and inspect it withfile <filename>.csv(which should reportwith CRLF line terminators) orod -c <filename>.csvto verify every line ends with\r \nand no extra blank lines appear afterPARTICIPANTSor the header row. - For inbound preamble skipping, select the Loop step in Orchestration Builder, click Debug Step against a test run with the 8-line preamble CSV attached, and confirm in Debug Outputs that iteration 1 starts directly on
CAD,1.3585,Indirect(line 9).