DB_Table.format
formatcolumnsformatlocaleerror_on_missing_columnson_problems
Group: Conversions
Documentation
Formats DB_Column
s within a Table
using a format string, Date_Time_Formatter
, or DB_Column
of format strings.
Arguments
columns
: The columns to format. The columns can have different types, but all columns must be compatible with any providedformat
value.format
: The type-dependent format string to use to format the values. Ifformat
is""
orNothing
, .to_text is used to format the value. In case of date/time columns, the format can also be aDate_Time_Formatter
. Ifformat
is aDB_Column
, it must be a text column.locale
: The locale in which the format should be interpreted. If aDate_Time_Formatter
is provided forformat
and thelocale
is set to anything else thanLocale.default
, then that locale will override the formatters locale.error_on_missing_columns
: Specifies if a missing input column should result in an error regardless of theon_problems
settings. Defaults toTrue
.on_problems
: Specifies how to handle if a problem occurs, raising as a warning by default.
Examples
Format the first and last boolean columns as 'Yes'/'No'.
table.format columns=[0, -1] format="Yes|No"
Format dates in a column using the format yyyyMMdd
.
table.format "birthday" "yyyyMMdd"
Format all columns in the table using the default formatter.
table.format
Errors
- If a column in
columns
is not in the input table, aMissing_Input_Columns
is raised as an error, unlesserror_on_missing_columns
is set toFalse
, in which case the problem is reported according to theon_problems
setting. - If a provided
format
value is not compatible with all selected columns, an Illegal_Argument error will be thrown, or a Date_Time_Format_Parse_Error in the case of a badly-formed date/time format. - If no columns have been selected for formatting, a
No_Input_Columns_Selected
error is raised.
Remarks
Supported Types
Value_Type.Date
Value_Type.Date_Time
Value_Type.Time
Value_Type.Integer
Value_Type.Float
Value_Type.Boolean
Value_Type.Date
, Value_Type.Date_Time
, Value_Type.Time
format strings
See Date_Time_Formatter
for more details.
Value_Type.Integer
, Value_Type.Float
format strings
Numeric format strings are specified by the Java DecimalFormat class. See https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html for a complete format specification.
Value_Type.Boolean
format strings
Format strings for Boolean
consist of two values that represent true
and false, separated by a |
.