Data Manipulation - Examples

Examples for the data manipulation step

Format a date

Let's say that using an API call you get a date under the following format 20230730T1028 and stores it in the variable departure_api. You can use the to_date filter (one of our custom jinja filters) to convert it into a python datetime object and display the date to the format that suits you using the strftime method of datetime objects.

# departure_api contains the following value "20230730T1028"

# departure_api is converted into a datetime object
{% set departure=departure_api | to_date %}

# departure is formated according to the following format "%H:%M - %d/%m/%Y"
{% set departure=departure.strftime("%H:%M - %d/%m/%Y")  %}

# After the execution of the block the variable departure contains
# the following value "10:28 - 30/07/2023"

Next page