Skip to main content
This covers a very common task that’s easy to get wrong: you have a batch of files (contracts, invoices, résumés, weekly reports, CSV exports) and you need key fields extracted into a table you can filter and compute on. There’s basically one way to get it wrong: asking the model to “read each one and summarize.” The first few come out accurate, then fields start going missing, and by the end the numbers are invented — with no way to tell which file it started failing on. This guide’s whole point is avoiding that: have the model write a script rather than read the files itself.

What you’ll get

The third artifact matters as much as the first two. A batch process that only reports successes is one that silently swallows failures.

The key call: read vs. script

The threshold is around five files. It isn’t a hard rule, it’s an empirical line: past five, manual verification costs enough that you won’t actually do it, so the process itself has to be verifiable.

Prerequisites

1

Upload the files

Put them in the workspace. Per-file caps: 512 MB for documents, 20 MB for images, 50 MB for code files. Total usage counts against your cloud drive quota (10 GB on Free, more on paid tiers).
2

Confirm the files are parseable

Scanned PDFs (image-based) and text PDFs are different animals. The former needs OCR, and accuracy degrades with layout complexity. Have the agent read one at random and confirm text comes out before going further.
3

Define the fields yourself

List the field names and types (text/number/date). “Have a look and see what fields there are” produces a different field set per file, and you can’t assemble a table from that.

Steps

Step 1: Sample the structure

Don’t start with all of them. Look at three:
Question 2’s “simply absent” clause is the important one. A missing field and a failed extraction are different things and must be distinguished before the script is written.

Step 2: Have it write a script, not do the work

Don’t skip “show it to me first.” The script is the only thing in this flow you can review in full — glancing at the regexes and field-location logic is much cheaper than reconciling 47 output rows afterwards.

Step 3: Run five, then run everything

Verify those five rows against the source files. Continue to the full run only if all five are correct. If even one is wrong, fix the script — never hand-edit the output, because a hand-edited row makes you believe the script works.

Step 4: Convert to a spreadsheet with formulas

The CSV is an intermediate. The deliverable has to compute:
“Use formulas, don’t hardcode” has to be stated explicitly. The default tends to be writing the computed number straight into the cell — the spreadsheet looks identical, but change any input and the total won’t move. This class of error surfaces after you’ve handed the file to someone else, which is the most expensive time to find it. See Excel spreadsheets.

Step 5: Work the failure list

After this, everything left in the failure list should genuinely require a human. If script-fixable entries remain, the batch isn’t finished.

Step 6: Accept the work

  1. Open the xlsx, pick 5 rows at random, verify each field against the source file
  2. Change one “total incl. tax” cell and confirm the totals row and net column move with it
  3. Confirm row count = success count, and success + failures = total file count
  4. Open failures.md and confirm each entry has a specific reason, not “parse failed”
Item 3 catches the most problems: if the numbers don’t add up, files were dropped silently.

Boundaries and failure modes

Variations

Split it in two: the script extracts source passages into a structured CSV, then the model reads those passages row by row and judges (e.g. “is this payment clause risky”). Don’t let the model parse the PDF and judge in one pass — when it’s wrong you can’t tell whether it misread or misjudged.
Connect the Feishu knowledge base and read them directly without downloading. See Feishu integration.
Freeze the finished script and prompt into a scheduled task. Every run bills for real — see Daily briefing.
xlsx is for computing, the web is for reading. See Publish a site.

Excel spreadsheets

Formula-first principle and limits

Files and cloud drive

Upload caps and quotas

Tool catalog

Parameters and defaults for read/write/exec tools

Sandbox

Where scripts actually run