# Generate e-commerce orders > How to create a synthetic US and Canada e-commerce orders CSV with realistic state and province weights, and which defects its anomaly profiles inject. Source: https://docs.tabalyst.com/generate/ecommerce/ (Tabalyst 0.8.3) The e-commerce example creates one CSV of online retail orders across the United States and Canada, each tied to a customer, a shipping timeline, a payment method and an order amount. ```console tabalyst generate --example ecommerce -o ecommerce-orders.csv ``` The file has 15 columns and 20,000 rows by default; `--rows` changes the count and `--seed` the data. The same seed gives the same file. ## What the file holds The 15 columns fall into three groups. Orders placed by the same customer share `customer_id`, `customer_segment`, `country`, `state_province` and `city`, drawn from a pool of 2,000 synthetic customers. | Group | Columns | | --- | --- | | Order (4) | `order_id` (`ORD-000001`, ...), `order_date`, `ship_date`, `delivery_date` | | Customer & geography (5) | `customer_id` (`CUST-00001`, ...), `customer_segment`, `country`, `state_province`, `city` | | Sale (6) | `currency`, `channel`, `payment_method`, `category`, `order_amount`, `order_status` | Rules tie the columns together. The clean file holds no exception to them: - **Geography (`US` 80%, `CA` 20%)**: `country` is `US` for about 80% of the customers and `CA` for about 20%. Within each country, `state_province` follows population weights across all 50 US states plus `DC` (for example `CA`, `TX`, `FL`, `NY` lead in the US) and all 13 Canadian provinces and territories (`ON` ~39%, `QC` ~22%, `BC` ~14%, `AB` ~12%). Each `state_province` picks from its main cities according to population weights. - **Currency**: `currency` is `USD` when `country` is `US`, and `CAD` when `CA`. - **Customer segment**: `customer_segment` is `Returning` (55%), `New` (30%) or `VIP` (15%). - **Channel and payment**: `channel` is `Web` (62%) or `Mobile App` (38%). `Apple Pay` appears only on `Mobile App` orders; `Credit Card`, `Debit Card`, `PayPal` and `Gift Card` appear on both channels. - **Categories and order status**: `category` has six values (`Apparel`, `Home & Kitchen`, `Electronics`, `Beauty & Health`, `Sports & Outdoors`, `Books & Media`). `order_status` is `Delivered`, `Shipped`, `Returned` or `Cancelled`: `Apparel` has a higher return rate (14%) and `Books & Media` a lower one (2%). - **Dates**: `order_date` runs from 2022 to `2026-09-24` with 25% annual growth, except `Shipped` orders which are placed between `2026-09-25` and `2026-09-29` (in transit at the reference date `2026-09-30`). `ship_date` is one day after `order_date` and empty when `Cancelled`. `delivery_date` is four days after `ship_date` and empty when `Cancelled` or `Shipped`. - **Order amount**: `order_amount` is drawn from 15 to 1,200 (log-normal draw, median 65), scaled by `category` (`Electronics` 2.6x, `Home & Kitchen` 1.3x, `Sports & Outdoors` 1.2x, `Apparel` 0.9x, `Beauty & Health` 0.7x, `Books & Media` 0.45x) and by the month of `order_date` (1.25x in November, 1.35x in December, 0.9x in January, 0.85x in February). These are synthetic records. Nothing in them comes from an actual store. ## Add defects on purpose The `dirty_realistic` anomaly profile keeps the clean file and writes an altered copy, a cell change log and a JSON summary (`-d` is required): ```console tabalyst generate --example ecommerce --rows 5000 -d ecom-dirty/ --anomaly-profile dirty_realistic ``` | Column | Defect | Rate | | --- | --- | ---: | | `order_id` | Copied from another row, creating duplicates | 0.5% | | `order_date` | Written day first, `30-09-2026` | 2% | | `country` | Replaced by `USA` (`US` rows) or `Canada` (`CA` rows) | 4% | | `city` | Written in capitals | 3% | | `city` | A space added at the end | 3% | | `category` | Written in lower case | 4% | | `payment_method` | Emptied | 2% | | `order_amount` | Written `$68.50`, with a currency prefix | 2.5% | | `order_amount` | Written with a decimal comma | 1.5% | | `order_amount` | Emptied | 1% | ## Break the rules on purpose The `rule_breaks` profile leaves the formats alone and breaks the rules that tie the columns together, each change tagged by its `class` in `changes.csv`: ```console tabalyst generate --example ecommerce -d ecom-rules/ --anomaly-profile rule_breaks ``` | Class | What changes | Rate | | --- | --- | ---: | | `delivery_before_order` | `delivery_date` set to `2021-01-15` on a `Delivered` order | 1.5% | | `delivered_when_cancelled` | `delivery_date` set to `2026-06-15` on a `Cancelled` order | 10% | | `currency_vs_country` | `currency` set to `CAD` on a `US` order | 1% | | `state_vs_country` | `state_province` set to `QC` on a `US` order | 1% | | `apple_pay_on_web` | `payment_method` set to `Apple Pay` on a `Web` order | 1.5% | | `negative_amount` | Minus sign added to `order_amount` on a `Delivered` order | 1% | ## Next steps - [Tabalyst Generate](https://docs.tabalyst.com/generate.md) explains packages and how to write your own anomaly profile. - The [CLI reference](https://docs.tabalyst.com/reference/cli/generate.md) lists every option. - [Generate CRM contacts](https://docs.tabalyst.com/generate/crm.md), [Generate computer offers](https://docs.tabalyst.com/generate/computer.md) and [Generate insurance customers](https://docs.tabalyst.com/generate/insurance.md) describe the other examples.