Filter and sort to get only the relevant data
You now have all the raw data in a Table format. The specification laid down some rules for filtering that data.
This is your first minimum effort attempt at implementing some filtering and sorting:
producer.robot
:
*** Settings ***
Documentation Inhuman Insurance, Inc. Artificial Intelligence System robot.
... Produces traffic data work items.
Library RPA.HTTP
Library RPA.JSON
Library RPA.Tables
*** Variables ***
${TRAFFIC_JSON_FILE_PATH}= ${OUTPUT_DIR}${/}traffic.json
*** Tasks ***
Produce traffic data work items
Download traffic data
${traffic_data}= Load traffic data as table
${filtered_data}= Filter and sort traffic data ${traffic_data}
*** Keywords ***
Download traffic data
Download
... https://github.com/robocorp/inhuman-insurance-inc/raw/main/RS_198.json
... ${TRAFFIC_JSON_FILE_PATH}
... overwrite=True
Load traffic data as table
${json}= Load JSON from file ${TRAFFIC_JSON_FILE_PATH}
${table}= Create Table ${json}[value]
RETURN ${table}
Filter and sort traffic data
[Arguments] ${table}
Filter Table By Column ${table} NumericValue < ${5.0}
Filter Table By Column ${table} Dim1 == BTSX
Sort Table By Column ${table} TimeDim False
RETURN ${table}

The logic works technically, but you think you might be able to improve the maintainability of the code a bit.
Everything is clear at the very moment you are implementing something. However, you or someone else often needs to return and modify the robot code even after a long time. It could be weeks, months, or even years later.
Statements using technical terms like NumericValue < ${5.0}
, Dim1 == BTSX
and Sort Table By Column ${table} TimeDim False
might be clear to you now. Still, you will forget what those mean in business terms sooner or later.
You could write some external documentation or link to the specification somewhere. Still, a better approach is to try and make your code document itself by using business terms in the code.
You decide to refactor your code to use named variables for those technical names and numbers:
producer.robot
:
*** Settings ***
Documentation Inhuman Insurance, Inc. Artificial Intelligence System robot.
... Produces traffic data work items.
Library RPA.HTTP
Library RPA.JSON
Library RPA.Tables
*** Variables ***
${TRAFFIC_JSON_FILE_PATH}= ${OUTPUT_DIR}${/}traffic.json
*** Tasks ***
Produce traffic data work items
Download traffic data
${traffic_data}= Load traffic data as table
${filtered_data}= Filter and sort traffic data ${traffic_data}
*** Keywords ***
Download traffic data
Download
... https://github.com/robocorp/inhuman-insurance-inc/raw/main/RS_198.json
... ${TRAFFIC_JSON_FILE_PATH}
... overwrite=True
Load traffic data as table
${json}= Load JSON from file ${TRAFFIC_JSON_FILE_PATH}
${table}= Create Table ${json}[value]
RETURN ${table}
Filter and sort traffic data
[Arguments] ${table}
${max_rate}= Set Variable ${5.0}
${rate_key}= Set Variable NumericValue
${gender_key}= Set Variable Dim1
${both_genders}= Set Variable BTSX
${year_key}= Set Variable TimeDim
Filter Table By Column ${table} ${rate_key} < ${max_rate}
Filter Table By Column ${table} ${gender_key} == ${both_genders}
Sort Table By Column ${table} ${year_key} False
RETURN ${table}
The future you will thank the present you for taking the time to make their life slightly easier when they one day return to modify this robot!