# PDF Table Validator - quality report + confidence score (`renev3408/pdf-table-validator`) Actor

Validates extracted PDF/CSV table data: flags empty cells, suspicious decimals, inconsistent column counts and row-sum mismatches; returns a quality score (0-100) and issue list. No OCR, no personal data.

- **URL**: https://apify.com/renev3408/pdf-table-validator.md
- **Developed by:** [Rene Vergara](https://apify.com/renev3408) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00 / 1,000 validated-tables

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

## PDF Table Validator

Validate extracted PDF tables for data quality issues and get detailed quality reports.

### What it does

This actor takes extracted PDF table data and validates it for common quality issues:

- **Empty cells**: Identifies cells that are null, undefined, or empty strings
- **Suspicious numbers**: Flags very long decimals that might be OCR errors
- **Inconsistent columns**: Detects tables with varying column counts across rows
- **Arithmetic checks** (optional): Checks for sum relationships between cells

### Input

#### Option 1: Pre-extracted table data (recommended)

```json
{
  "tableData": "{\"data\":[[\"Item\",\"Price\",\"Qty\",\"Total\"],[\"Apple\",\"1.50\",\"10\",\"15.00\"],[\"Banana\",\"0.75\",\"5\",\"3.75\"]],\"rows\":3,\"columns\":4}",
  "includeArithmeticChecks": false
}
```

#### Option 2: PDF URLs (table extraction not yet implemented)

```json
{
  "pdfUrls": ["https://example.com/table.pdf"]
}
```

### Output

Returns a validation report with:

- **detectedIssues**: Array of issues found with type, severity, and position
- **totalIssues**: Total count of issues
- **qualityScore**: 0-100 score (100 = perfect quality)
- **summary**: Overview of quality level (high/medium/low)

### Example

**Input:**

```json
{
  "tableData": "{\"data\":[[\"A\",\"B\",\"Sum\"],[\"10\",\"20\",\"30\"],[\"5\",\"5\",\"11\"]],\"rows\":3,\"columns\":3}",
  "includeArithmeticChecks": true
}
```

**Output:**

```json
{
  "source": "pre_extracted",
  "tableData": {...},
  "validationReport": {
    "hasArithmeticChecks": true,
    "detectedIssues": [
      {
        "type": "sum_mismatch",
        "severity": "medium",
        "description": "Last cell (11) may not match sum of previous cells (10.00)",
        "cellPosition": "R3C3"
      }
    ],
    "totalIssues": 1,
    "highConfidenceCells": 5,
    "lowConfidenceCells": 1,
    "qualityScore": 95,
    "summary": {
      "totalCells": 9,
      "issuesFound": 1,
      "qualityLevel": "high"
    }
  }
}
```

### Usage

1. Get your Apify API token from [Apify Console](https://console.apify.com/)
2. Install the Apify CLI: `npm install -g apify-cli`
3. Login: `apify login`
4. Build and push: `apify push .`
5. Run: `apify run --actor-id your-username/pdf-table-validator`

### License

MIT

# Actor input Schema

## `pdfUrls` (type: `array`):

One or more http(s) URLs of text-layer PDFs with tables already extracted. The tables should be in JSON format with a 'data' array of rows. Leave empty when you paste table data below.

## `tableData` (type: `string`):

Alternative to pdfUrls: a JSON string containing table data with 'data', 'rows', and 'columns' fields. Format: { data: \[\[cell1, cell2], \[cell3, cell4]], rows: 2, columns: 2 }. The prefilled sample is a small invoice table with one empty cell and a wrong total (44.50 expected, 45.50 shown). Turn on arithmetic checks below to see the total flagged.

## `includeArithmeticChecks` (type: `boolean`):

Enable checks for sums, subtotals, and other arithmetic relationships between cells (experimental). Turn this on with the sample table to see the wrong total flagged.

## Actor input object example

```json
{
  "tableData": "{\"data\":[[\"Item\",\"Qty\",\"Unit price\",\"Amount\"],[\"Widget A\",\"2\",\"10.00\",\"20.00\"],[\"Widget B\",\"3\",\"5.50\",\"16.50\"],[\"Widget C\",\"\",\"4.00\",\"8.00\"],[\"Total\",\"\",\"\",\"45.50\"]],\"rows\":5,\"columns\":4}",
  "includeArithmeticChecks": false
}
```

# Actor output Schema

## `results` (type: `string`):

One dataset item per validated table: source, tableData and validationReport (detectedIssues, totalIssues, qualityScore 0-100, summary).

# 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 = {
    "tableData": "{\"data\":[[\"Item\",\"Qty\",\"Unit price\",\"Amount\"],[\"Widget A\",\"2\",\"10.00\",\"20.00\"],[\"Widget B\",\"3\",\"5.50\",\"16.50\"],[\"Widget C\",\"\",\"4.00\",\"8.00\"],[\"Total\",\"\",\"\",\"45.50\"]],\"rows\":5,\"columns\":4}"
};

// Run the Actor and wait for it to finish
const run = await client.actor("renev3408/pdf-table-validator").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 = { "tableData": "{\"data\":[[\"Item\",\"Qty\",\"Unit price\",\"Amount\"],[\"Widget A\",\"2\",\"10.00\",\"20.00\"],[\"Widget B\",\"3\",\"5.50\",\"16.50\"],[\"Widget C\",\"\",\"4.00\",\"8.00\"],[\"Total\",\"\",\"\",\"45.50\"]],\"rows\":5,\"columns\":4}" }

# Run the Actor and wait for it to finish
run = client.actor("renev3408/pdf-table-validator").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 '{
  "tableData": "{\\"data\\":[[\\"Item\\",\\"Qty\\",\\"Unit price\\",\\"Amount\\"],[\\"Widget A\\",\\"2\\",\\"10.00\\",\\"20.00\\"],[\\"Widget B\\",\\"3\\",\\"5.50\\",\\"16.50\\"],[\\"Widget C\\",\\"\\",\\"4.00\\",\\"8.00\\"],[\\"Total\\",\\"\\",\\"\\",\\"45.50\\"]],\\"rows\\":5,\\"columns\\":4}"
}' |
apify call renev3408/pdf-table-validator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,renev3408/pdf-table-validator"
        }
    }
}
```

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/4GiMcDhNPZwInbv0p/builds/uAr51Uk3ISHDkukB2/openapi.json
