---
name: doc-cleaner
description: Convert PDF, DOCX, XLSX, and text files to clean, structured Markdown. CJK-friendly, table-friendly, privacy-first.
version: 1.0.0
metadata: {"openclaw":{"emoji":"📄","homepage":"https://github.com/notoriouslab/doc-cleaner","requires":{"bins":["python3"]}}}
---

<!-- doc-cleaner, via Skill Issue (https://www.skillissue.bot/skills/doc-cleaner). Source: https://github.com/notoriouslab/doc-cleaner/tree/55e3c472ac4875c3bb923b2d82821fec15444cc0 -->

# doc-cleaner

Convert documents (PDF, DOCX, XLSX, TXT) to clean, structured Markdown.

## When to use

- User asks to convert a document to Markdown
- User wants to extract text or tables from PDF/DOCX/XLSX files
- User wants to clean up bank statements or financial documents
- User asks to process a batch of documents in a directory

## Commands

### Convert a single file (no AI, fastest)
```bash
python3 {baseDir}/cleaner.py --input "{{file_path}}" --ai none
```

### Convert a single file with AI structuring
```bash
python3 {baseDir}/cleaner.py --input "{{file_path}}" --ai gemini
```

### Convert a single file with Groq structuring
```bash
python3 {baseDir}/cleaner.py --input "{{file_path}}" --ai groq
```

### Convert all files in a directory
```bash
python3 {baseDir}/cleaner.py --input "{{directory}}" --ai none --output-dir "{{output_dir}}"
```

### Preview without writing (dry run)
```bash
python3 {baseDir}/cleaner.py --input "{{file_path}}" --dry-run --verbose
```

### Get machine-readable result summary
```bash
python3 {baseDir}/cleaner.py --input "{{file_path}}" --ai none --summary
```

The `--summary` flag prints a JSON summary to stdout after processing:
```json
{"version":"1.0.0","total":3,"success":2,"failed":1,"files":[{"file":"report.pdf","output":"./output/report.md","status":"ok"},{"file":"scan.pdf","output":null,"status":"no_content"},{"file":"data.xlsx","output":"./output/data.md","status":"ok"}]}
```

## Options

| Flag | Description |
|---|---|
| `--input, -i` | File or directory to process (required, non-recursive) |
| `--output-dir, -o` | Output directory (default: ./output) |
| `--ai` | `gemini`, `groq`, `ollama`, or `none` (default: from config or gemini) |
| `--password` | PDF decryption password |
| `--config` | Path to config JSON |
| `--summary` | Print JSON summary to stdout after processing |
| `--dry-run` | Preview without writing files |
| `--verbose` | Enable debug logging |

## Supported formats

PDF (native, scanned, encrypted), DOCX, XLSX, XLS, CSV, TXT, MD

## Exit codes

| Code | Meaning |
|---|---|
| 0 | All files processed successfully |
| 1 | Some files failed (partial success) |
| 2 | No processable files found or config error |

## Notes

- Output defaults to `./output/` relative to current directory
- For scanned PDFs, AI mode (`gemini`, `groq`, or `ollama`) gives much better results
- `--ai none` requires zero API keys and zero network access
- CJK encoding (Big5, CP950, UTF-16) is auto-detected
- Tables in DOCX and XLSX are preserved as Markdown pipe tables


## Files this skill uses
These files come with the skill. Open the ones the instructions mention when you need them:
- `cleaner.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/cleaner.py
- `CHANGELOG.md`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/CHANGELOG.md
- `CONTRIBUTING.md`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/CONTRIBUTING.md
- `README.en.md`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/README.en.md
- `README.md`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/README.md
- `ReadMe.txt`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/ReadMe.txt
- `SECURITY.md`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/SECURITY.md
- `ai/__init__.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/ai/__init__.py
- `ai/base.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/ai/base.py
- `ai/gemini.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/ai/gemini.py
- `ai/groq.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/ai/groq.py
- `ai/mlx.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/ai/mlx.py
- `ai/nvidia.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/ai/nvidia.py
- `ai/ollama.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/ai/ollama.py
- `classifiers/__init__.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/classifiers/__init__.py
- `classifiers/noise.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/classifiers/noise.py
- `classifiers/pdf_classifier.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/classifiers/pdf_classifier.py
- `classifiers/pii.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/classifiers/pii.py
- `config.example.json`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/config.example.json
- `core.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/core.py
- `docs/index.html`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/docs/index.html
- `macapp/__init__.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/macapp/__init__.py
- `macapp/__main__.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/macapp/__main__.py
- `macapp/app.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/macapp/app.py
- `macapp/mdpreview.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/macapp/mdpreview.py
- `macapp/settings.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/macapp/settings.py
- `output/__init__.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/output/__init__.py
- `output/epub.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/output/epub.py
- `output/markdown.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/output/markdown.py
- `parsers/__init__.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/__init__.py
- `parsers/_platform.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/_platform.py
- `parsers/_tableutil.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/_tableutil.py
- `parsers/_textutil.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/_textutil.py
- `parsers/docx.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/docx.py
- `parsers/dxf.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/dxf.py
- `parsers/epub.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/epub.py
- `parsers/iwork.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/iwork.py
- `parsers/jsonl.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/jsonl.py
- `parsers/numbers.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/numbers.py
- `parsers/pdf.py`: https://raw.githubusercontent.com/notoriouslab/doc-cleaner/55e3c472ac4875c3bb923b2d82821fec15444cc0/parsers/pdf.py
- and 37 more in the source: https://github.com/notoriouslab/doc-cleaner/tree/55e3c472ac4875c3bb923b2d82821fec15444cc0
