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 offalse
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
totrue
and have Liquibase automatically trim your header. This results in the file headerid,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 (defaults file) |
|
Global flow file argument (example) |
|
Global CLI parameter |
|
JVM system property (JAVA_OPTS Environment Variable) |
|
Liquibase Environment Variables |
|
For more information, see Working with Command Parameters.