Skip to main content

data-transformation Scenario 1 — Extract Prices, Remove Currency, Cast to Float, Export CSV

Written by RTILA X Engineering Team

Beginner ~4 min

What You'll Learn

Transform scraped data using replace and cast

Real-World Use Case

Normalising prices before export

LIVE DEMO

Product NameRaw Price
Wireless Mouse $299.99
Mechanical Keyboard €149.50
USB-C Hub $89.00
Bluetooth Speaker £199.99
Webcam $45.99
4K Monitor $1,299.00
Standing Desk $75.50
Laptop Stand $549.99
EXPECTED OUTPUT

RTILA X PROJECT JSON

    {
  "name": "Normalize_Prices_And_Export",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/data-transformation/1"
    ],
    "headless": false,
    "navigation_timeout": 30000,
    "max_concurrent_workers": 1,
    "humanoidEnabled": true,
    "humanoidSensitivity": "medium"
  },
  "datasets": {
    "normalized_prices": {
      "item_selector": "css=table.price-table tbody tr",
      "properties": [
        {
          "name": "name",
          "type": "text",
          "selector": "css=td:nth-child(1)"
        },
        {
          "name": "price",
          "type": "text",
          "selector": "css=td:nth-child(2)",
          "transformations": [
            {
              "type": "replace",
              "find": "[\\$€£,]",
              "replace_with": "",
              "flags": "g"
            },
            {
              "type": "cast",
              "to": "float"
            }
          ]
        }
      ]
    }
  },
  "commands": [
    {
      "command": "goto",
      "params": {
        "url": "https://learn.rtila.com/scenarios/data-transformation/1"
      }
    },
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=table.price-table"
      }
    },
    {
      "command": "extract_data",
      "params": {
        "dataset": "normalized_prices"
      }
    },
    {
      "command": "comment",
      "params": {
        "text": "CSV export would occur in the trigger chain after extraction"
      }
    }
  ]
}
  

Transformations are applied at the dataset property level. The replace operation removes currency symbols, and the cast operation converts the string to a float for CSV export.

Did you complete this scenario?

Ready to run this automation?

Copy the project JSON above, open RTILA X, create a new project, and paste it.

This scenario covers 1 RTILA X command and is referenced in 2 learning articles.

Continue Learning

Was this helpful?