trim-load-data-file-header

--trim-load-data-file-header is a global Boolean parameter. You can use it to trim whitespace from CSV headers that you call with the loadData Change Type. It is available in Liquibase 4.29.0 and later. The default value is false.

Uses

loadData accepts input from a Comma-Separated Value (CSV) file, which contains a header (a comma-separated list of column names) and any number of data rows. In Liquibase 4.4.0 and later, in order to conform to RFC 4180, spaces are considered part of the header name and are no longer trimmed by default.

For example, if you have the CSV header id, first, last (with spaces after each comma), Liquibase parses the column names as id, first, and last (with leading spaces). However, you may not have intended to include spaces in individual column names. If you try to call on the column first (without a leading space) when you specify attributes for loadData, Liquibase displays this error:

ERROR: Exception Primary Reason:  ORA-00904: " first": invalid identifier

You can resolve this error in two ways:

  • Leave --trim-load-data-file-header at its default value of false and manually remove spaces from your CSV header. This is best if you want to ensure CSV headers inherently match RFC 4180 or if you want to avoid setting additional Liquibase parameters.
  • Set --trim-load-data-file-header to true and have Liquibase automatically trim your header. This results in the file header id,first,last, which lets you call on the intuitive column names. This is best if you prefer to keep spaces in your CSV header for aesthetic reasons or if it would be difficult to update the files yourself.

Syntax

You can set this parameter in the following ways:

Option Syntax
Liquibase properties file
liquibase.trimLoadDataFileHeader: <true|false>
Global flow file argument (example)
stages:
  Default:
    actions:
      - type: liquibase
        command: update
        globalArgs: { trim-load-data-file-header: "<true|false>" }
Global CLI parameter
liquibase
 --trim-load-data-file-header=<true|false> update
 --changelog-file=example-changelog.xml

JVM system property (JAVA_OPTS Environment Variable)

JAVA_OPTS=-Dliquibase.trimLoadDataFileHeader=<true|false>
Liquibase Environment Variables
LIQUIBASE_TRIM_LOAD_DATA_FILE_HEADER=<true|false>

For more information, see Working with Command Parameters.