# Messy sales table → clean summary workbook (`keiwy/messy-sales-to-summary`) Actor

Upload a messy CSV/XLSX sales or ledger table; get back a clean summary.xlsx with KPIs and pivots by category, region, and month. Pay per event $0.10 per successful workbook.

- **URL**: https://apify.com/keiwy/messy-sales-to-summary.md
- **Developed by:** [KEith wy](https://apify.com/keiwy) (community)
- **Categories:** AI, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.10 / summary workbook generated

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Sales CSV to Excel Summary Report — Clean Messy Sales Data, Pivot by Category / Region / Month

**Apify Store:** https://apify.com/keiwy/messy-sales-to-summary

Upload a **messy sales / orders CSV or Excel file** (Shopify, Stripe, WooCommerce, CRM or POS export) → get back **one clean `summary.xlsx`** with KPIs and pivot tables in ~4 seconds. No Excel formulas, no pivot-table setup, no AI key.

| At a glance | |
|---|---|
| **Input** | `.csv`, `.xlsx`, `.xls` — upload or paste a direct URL |
| **Output** | `summary.xlsx` with 5 sheets: **KPIs, ByCategory, ByRegion, ByMonth, CleanDetail** |
| **Cleans** | messy column names (aliases), mixed-case categories & regions, blank / zero quantities, bad prices; rows whose date is not `YYYY-MM-DD` are dropped and counted (`rows_dropped`) |
| **Speed** | **~4 s** for a 20-row file (measured below) |
| **Price** | **$0.10 per summary workbook** (pay-per-event, once per successful run) |

### Measured demo (real Apify platform run, 2026-10-20)

| Field | Value |
|---|---|
| **Run id** | `Y5nh27yc2xSQh6SU1` (SUCCEEDED) |
| **Input** | empty `{}` → default sample file [`sample_input.csv`](https://gist.githubusercontent.com/KEithwy1030/c9aa87a298dbdb64574d07eae43658c3/raw/sample_input.csv) (20 messy rows: blank qty, qty=0, one `01/05/2025` date, mixed-case labels) |
| **Duration** | 4.4 s |
| **Rows in → out** | **20 → 16** (4 invalid rows dropped and counted) |
| **Output** | `summary.xlsx` (8.4 KB, 5 sheets) in the run's Key-value store + 1 stats row in Dataset |
| **Platform compute** | ~$0.0003 |
| **PPE event** | `summary-workbook` ×1 = **$0.10** for a customer (owner self-test runs are not billed) |

**KPIs sheet (real output):**

| metric | value |
|---|---|
| rows_in / rows_out / rows_dropped | 20 / 16 / 4 |
| total_revenue | 2,128.95 |
| total_orders | 15 |
| avg_order_value | 141.93 |
| date range | 2025-01-03 → 2025-02-20 |
| currencies | USD |

**ByCategory sheet (real output):**

| category | orders | units | revenue | revenue_share |
|---|---|---|---|---|
| Software | 4 | 7 | 847.95 | 39.8% |
| Services | 4 | 7 | 799.00 | 37.5% |
| Hardware | 7 | 31 | 482.00 | 22.6% |

**ByRegion:** EU 810.50 (38.1%) · NA 674.97 (31.7%) · APAC 643.48 (30.2%). **ByMonth:** 2025-01 = 1,189.98 · 2025-02 = 938.97.

### Who it's for

- Shop owners / ops who export orders from **Shopify, Stripe, WooCommerce, Square, a CRM or POS** and need a weekly sales summary
- Freelance bookkeepers and analysts who receive messy client spreadsheets
- Anyone automating a **sales report** via API / Make / Zapier (one run per file)

### Input example (API / JSON)

```json
{
  "fileUrl": "https://gist.githubusercontent.com/KEithwy1030/c9aa87a298dbdb64574d07eae43658c3/raw/sample_input.csv"
}
```

Dataset output (real, run `Y5nh27yc2xSQh6SU1`):

```json
{
  "rows_in": 20,
  "rows_dropped": 4,
  "rows_out": 16,
  "sheets": ["KPIs", "ByCategory", "ByRegion", "ByMonth", "CleanDetail"],
  "input_filename": "sample_input.csv",
  "summaryKey": "summary.xlsx",
  "summaryBytes": 8355
}
```

### Input columns

Required (aliases accepted, case-insensitive):

| Canonical | Aliases (examples) |
|-----------|--------------------|
| `date` | order_date |
| `order_id` | order_no |
| `product` | item |
| `category` | cat |
| `quantity` | qty |
| `unit_price` | price |
| `region` | area |

Optional: `currency` (default `USD`). Rows with non-ISO / unparseable dates (e.g. `01/05/2025`, `not a date`), empty/≤0 quantity or invalid price are dropped and counted in `rows_dropped` — export dates as `YYYY-MM-DD` for best results.

### Output location

- **Key-value store:** `summary.xlsx` (download link also in the Dataset row as `summaryUrl`)
- **Dataset:** one stats row (`rows_in`, `rows_out`, `rows_dropped`, `sheets`, `summaryUrl`)

### Pricing

**Pay per event:** `summary-workbook` = **$0.10** per successful run (one workbook). Failed runs are not charged.

### Honest limits

- Not a chatbot and not a custom column mapper — columns must match the names/aliases above
- No currency conversion, no charts / PowerPoint
- One file per run

### Related

- Local business email leads from OpenStreetMap → [keiwy/local-biz-leads-email](https://apify.com/keiwy/local-biz-leads-email)
- Amazon / Shopify / eBay listing copy → [keiwy/listing-copy-pack](https://apify.com/keiwy/listing-copy-pack)

# Actor input Schema

## `fileUrl` (type: `string`):

Upload your messy sales table, or paste a direct download URL. Accepted: .csv, .xlsx, .xls.

## Actor input object example

```json
{
  "fileUrl": "https://gist.githubusercontent.com/KEithwy1030/c9aa87a298dbdb64574d07eae43658c3/raw/sample_input.csv"
}
```

# Actor output Schema

## `summaryXlsx` (type: `string`):

Cleaned workbook in the run's default key-value store.

## `stats` (type: `string`):

rows_in / rows_out / dropped and download link.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "fileUrl": "https://gist.githubusercontent.com/KEithwy1030/c9aa87a298dbdb64574d07eae43658c3/raw/sample_input.csv"
};

// Run the Actor and wait for it to finish
const run = await client.actor("keiwy/messy-sales-to-summary").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "fileUrl": "https://gist.githubusercontent.com/KEithwy1030/c9aa87a298dbdb64574d07eae43658c3/raw/sample_input.csv" }

# Run the Actor and wait for it to finish
run = client.actor("keiwy/messy-sales-to-summary").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "fileUrl": "https://gist.githubusercontent.com/KEithwy1030/c9aa87a298dbdb64574d07eae43658c3/raw/sample_input.csv"
}' |
apify call keiwy/messy-sales-to-summary --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,keiwy/messy-sales-to-summary"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/MDpGbOpmKenOxDBoW/builds/17n04W0jBzeVziFlg/openapi.json
