TypeConverter Node
The TypeConverter Node
gets data of one type to the Input Port
, modifies the type of data, sends modified data to the Output Port
.
The example above employs 2 TypeConverter Nodes
.
The first TypeConverter Node
gets a string containing datetime
, parses the string, converts the parsed data into float timestamp
.
The second TypeConverter Node
gets a float number containing timestamp
data, and converts into the string type containing datetime
data.
The strftime()
and strptime()
methods are used to format and parse date
, datetime
, and time
objects.
Below the examples of converting datetime
to timestamp
.
Input Port | Output Port |
---|---|
data type: string value: "2022-11-21 14:58:00:000000" | data type : float value: 1669031880.0 code: "%Y-%m-%d %H:%M:%S:%f" |
data type: string value: "2022-11-21 14:58:00" | data type : float value: 1669031880.0 code: "%Y-%m-%d %H:%M:%S" |
data type: string value: "2022-11-21 15:00:00" | data type : float value: 1669032000.0 code: "%Y-%m-%d %H:%M:%S" |
data type: string value: "15:00:00 2022-11-21" | data type : float value: 1669032000.0 code: "%H:%M:%S %Y-%m-%d" |
And the examples of converting timestamp
to datetime
.
Input Port | Output Port |
---|---|
data type: float value: 1669031880.0 | data type : string value: "2022-11-21 11:58:00:000000" code: "%Y-%m-%d %H:%M:%S:%f" |
data type: float value: 1669031880.0 | data type : string value: "2022-11-21 11:58:00" code: "%Y-%m-%d %H:%M:%S" |
data type: float value: 1669032000.0 | data type : string value: "2022-11-21 12:00:00" code: "%Y-%m-%d %H:%M:%S" |
data type: float value: 1669032000.0 | data type : string value: "12:00:00 2022-11-21" code: "%H:%M:%S %Y-%m-%d" |
The TypeConverter Node
allows to convert other data types.
Input Port | Output Port |
---|---|
data type: bool value: False | data type : int value: 0 code: None |
data type: bool value: True | data type : int value: 1 code: None |
data type: bool value: True | data type : float value: 1.0 code: None |
data type: bool value: False | data type : float value: 0.0 code: None |
data type: object value: {"key" : "value"} | data type : bool value: true code: None |
data type: object value: {} | data type : bool value: false code: None |