Examples

Example DuckDB SQL transformations for messy files.

These examples are intentionally boring. That is the point. Bendit is for real-world file cleanup work.

Download sample CSV

Clean names, dates and amounts

select
  trim(customer_name) as customer_name,
  try_cast(order_date as date) as order_date,
  replace(amount, ',', '.')::decimal(18,2) as amount
from orders
where customer_name is not null;

Find duplicate customer names

select
  lower(trim(customer_name)) as normalized_name,
  count(*) as count
from orders
group by normalized_name
having count(*) > 1
order by count desc;

Export a clean subset

select
  order_id,
  customer_name,
  order_date,
  amount
from clean_orders
where amount > 0
order by order_date;