.. _auto_file_write: *WRITE TO FILE* =============== Modifies an existing file by replacing text content using exact string matching. Accepts a file attachment ID, file path, or attachment name, and supports replacing the first or all occurrences of the target string. Use this worker to perform in-place text edits on platform-managed files (max 500 MB). When to use ----------- Tagged: ``file``, ``file_write``, ``in_place``, ``replace``, ``string_replace``, ``text_edit``, ``write``. Inputs ------ .. list-table:: :header-rows: 1 :widths: 20 20 20 20 20 20 * - Label - ID - Type - Default - Required - Description * - File - file - file - — - ✓ - The file to modify — supply a numeric attachment ID, an absolute/relative file path, or an attachment name registered on the platform; required. * - Old String - old_string - textarea - — - ✓ - The exact literal text to search for in the file; must be non-empty and must differ from new_string — supports multi-line strings via the code editor. * - New String - new_string - textarea - — - ✓ - The replacement text that will be written in place of old_string; may be an empty string to effectively delete the matched text — supports multi-line strings via the code editor. * - Replace All - replace_all - boolean - False - - When true, every occurrence of old_string in the file is replaced; when false (default), only the first occurrence is replaced. Outputs ------- .. list-table:: :header-rows: 1 :widths: 20 20 20 20 * - Label - ID - Type - Description * - File - file - file - The modified file returned as a platform file reference pointing to the same physical path that was overwritten in place. * - Replacements Made - replacements - number - Integer count of how many substitutions were actually performed; will be 0 if old_string was not found (which also raises an error). * - Bytes Written - bytes_written - number - Total number of bytes written back to disk after the replacement; useful for sanity-checking file size changes. * - Status - status - string - Human-readable success message summarising the number of replacements made and bytes written, e.g. 'Success: Made 2 replacement(s) in model.key (4096 bytes written)'. Disciplines ----------- - data.io.file .. raw:: html

Auto-generated from platform schema. Worker id: file_write. Schema hash: 6efd4818b5ef. Hand-curated docs in workerexamples/ override this page when present.