Create Delimited Line using Transformed Data
Overview
To create a delimited line is easy once your processors are configured. The processors are called automatically when the column is accessed allowing the new row to be created easily. The following examples show how to quickly create a new row that can then be output to a new file which can be used once verification issues are resolved.
NOTE: If one or more VerificationExceptions are thrown (and/or logged), you may receive null values when they cannot be processed due to the exception. It is critical to always check the log and resolve all verification exceptions before creating the final file.
Methods:
String createDelimitedRow(int rowIndex, List<String> columnNames)
String createDelimitedRow(int masterRowIndex, List<String> columnNames, String delimiter)
String createDelimitedRow(int masterRowIndex, List<String> columnNames, String delimiter, boolean escapeSingleQuotes)
String createDelimitedRow(int masterRowIndex, List<String> columnNames, String delimiter, boolean trim, boolean escapeSingleQuotes )
Simplifies creating a delimited row from values in the table. For each columnName provided in the list, the value will be replaced with table value. If the value is not a column name, it will be added as a literal. All configured processors and/or extensions are called to verify, cleanse the values before returning the cleansed value. Any column name passed in columnNames List but not found in the table will be treated as a constant value and included in the delimited line with not additional processing.
NOTE: the try/catch block to make sure the out file is closed. This is REQUIRED as if the close is not performed, the file will remain in an open state and may not be accessible for writing until Andi is restarted.
out = new File( "c:/final/updated_name.csv" ).newWriter()
try {
table.eachRow() { rowIndex, table ->
context.testExecutionCancelled()
out.write( table.createDelimitedRow( rowIndex, ['first_name','last_name'] ) )
}
} finally {
out.close()
}
Methods:
String createDelimitedRow(List<String> literalValues)
String createDelimitedRow(List<String> literalValues, String columnDelimiter)
String createDelimitedRow(List<String> literalValues, String delimiter, boolean trim)
String createDelimitedRow(List<String> literalValues, String delimiter, boolean trim, boolean escapeSingleQuotes )
Convenience methods provided to create a delimited row out of literal values. If you included a column name in the literalValues parameter, it will be added to the final value as the literal column name.