Python SDK: Documents: opening files
ctx.documents() reads allowed files. Loading is synchronous; methods on a loaded Document run locally.
Examples are fragments inside def run(ctx):. All SDK methods are synchronous; do not add await.
Methods
from_url
ctx.documents().from_url(url, name='document') -> Document
| Argument | Type | Required | Purpose |
|---|---|---|---|
url |
str |
Yes | Permitted source HTTP(S) URL. |
name |
str |
No, see the signature default | Field, header, file, credential, or metric name, depending on the method. |
Result: Document. An SDK object; use its methods instead of emitting it directly.
Download a file up to 10 MiB through the current source's network settings. Address, redirect, robots.txt, request-rate, and proxy rules still apply. The name is taken from the URL; supply it as the second argument if the URL has no extension.
result = ctx.documents().from_url(ctx.param('file_url'), 'report.csv')
from_bytes
ctx.documents().from_bytes(content, name) -> Document
| Argument | Type | Required | Purpose |
|---|---|---|---|
content |
str | bytes |
Yes | Supplied content; method limits apply. |
name |
str |
Yes | Field, header, file, credential, or metric name, depending on the method. |
Result: Document. An SDK object; use its methods instead of emitting it directly.
Parse bytes you already have, up to 8 MiB. The name helps identify text and older Office formats; the service also checks the content signature.
result = ctx.documents().from_bytes('sku,price\nA-1,1250', 'report.csv')
coordinates
ctx.documents().coordinates() -> SheetCoordinates
No arguments.
Result: SheetCoordinates. An SDK object; use its methods instead of emitting it directly.
Excel addressing helpers that do not load a document or make a network request.
result = ctx.documents().coordinates()
Errors and execution context
All calls are synchronous. Invalid arguments or malformed source data can raise ValueError/TypeError; a platform refusal or unavailable service raises RuntimeError. Missing elements/values return None or an empty collection only where explicitly documented. Do not convert every exception into an empty successful result. External-service methods are unavailable in export transformations; see transformation limits and environment.