read_file
Opens a file from the filesystem and returns its contents as a string. This is useful for reading configuration files, templates, or other text-based data during procedure execution.
Syntax
read_file(file_path)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| file_path | string | Yes | The absolute path to the file to read. |
Returns
Type: string
The full contents of the file as a string.
Examples
Reading a text file:
read_file("/pb/data/template.txt")
Returns the contents of template.txt as a string.
Using file contents in a field mapping:
replace(read_file("/pb/data/email_template.html"), "{{name}}", [full_name])
Reads an HTML template and substitutes a placeholder with the record's full_name field.
Notes
- The file path must be an absolute path within the container's filesystem.
- The file is read in text mode, so this function is intended for text files only. For binary files or attachments, use
open_fileinstead. - If the file does not exist or cannot be read, a standard file I/O error will be raised.
- Files within the Precision Bridge data volume are typically located under the
/pbdirectory.
Comments
0 comments
Please sign in to leave a comment.