Block reference / General

File action

Write a value to a TXT, CSV or JSON file on the computer, append to one, or delete a file.

In both appsWarpX BrowserWarpX Phone

Use this block to keep what a run produced in a file you can open later: a line per finished account, a CSV of results for Excel, a JSON list for another tool. Many profiles can append to the same file at once without losing a line. It can also delete a file, for example a download you have finished with. It works only in the WarpX Browser desktop app.

The File action block's settings, filled in as in the example below.

Settings

Options

Write puts data into a file. Delete removes the file at File path.

ExampleWrite
File path

The whole path of the file, from the drive. A leading ~ means your home folder. The folder button opens a file dialog. You can put variables in it, such as C:\Users\me\Documents\{{$date('YYYY-MM-DD')}}.csv. Missing folders are created when writing.

ExampleC:\Users\me\Documents\results.csv
Data to writewhen Options is Write

From a variable writes a variable's value as it is: text, a list or an object. Text writes what you type in the box, with any {{...}} filled in.

ExampleFrom a variable
Variable namewhen Data to write is From a variable

The variable to write, as a bare name or as {{variables.result}}. A dotted name such as result.items writes a part of it. A variable that does not exist stops the block with an error.

Exampleresult
Textwhen Data to write is Text

The text to write. Variables can go in it.

Example{{variables.email}},{{variables.status}}
Formatwhen Options is Write

TXT writes text, a list one item per line. CSV writes rows: a list of objects becomes rows under a header made from their keys, and a list of lists is written row by row. JSON writes the value as JSON.

ExampleCSV
Write modewhen Options is Write

Overwrite replaces the file. Append adds to the end: in TXT on a line of its own, in CSV as new rows, each value put under the existing header by column name, in JSON as items added to the list the file holds.

ExampleAppend

Every block also has the shared block settings — a description, Disable block and what to do on an error. Fields that take text accept data from earlier blocks.

What it hands on

Hands on the file's full path, which the next block reads as {{prevBlockData}}. The log line says Wrote, Appended to or Deleted and the path, or Nothing to delete when the file was already gone. Leaves by its single output.

Example: Add one row per profile to a results CSV

  1. Start
  2. New tab
  3. Forms
  4. JavaScript code
  5. File action
Where File action sits in the example workflow.
  1. Earlier in the workflow, collect what you want to keep into a variable named result, such as {"profile": "Shop 14", "email": "[email protected]", "status": "verified"} from JavaScript code or Data mapping.
  2. Add File action at the end of the workflow and choose Write.
  3. Set File path to C:\Users\me\Documents\results.csv.
  4. Choose From a variable and type result.
  5. Choose CSV and Append.
  6. Run the workflow on several profiles at once. Each adds its own row, under a profile,email,status header the first run writes.
  7. Open results.csv in Excel: accented names read correctly.

On WarpX Phone

  • On WarpX Phone this works on files on this computer, not on the phone. To copy a file between the phone and this computer, use the phone's Transfer file block.

Good to know

  • Desktop app only. In the browser extension the block is not in the list.
  • Paths must be full, starting from a drive such as C:\ or from /. A relative path is refused, because it would depend on where the app was started.
  • Writing to one file is done one block at a time, so profiles appending together never overwrite each other's lines.
  • A new CSV file starts with a UTF-8 byte order mark, so Excel shows accented and Vietnamese text correctly. Appending keeps the file's header: a key with no column of that name in it is left out.
  • CSV and JSON accept text that holds JSON, such as a variable set from an API response, and read it as the list or object it describes.
  • JSON Append needs the file to hold a list, such as []. A file that holds an object stops the block and asks you to choose Overwrite. A file that does not exist yet starts a list.
  • Delete removes one file of any kind, never a folder. A file that is already gone is not an error.
  • A file open in Excel cannot be changed: close it first, or the block stops saying the file is open in another program.

See also

  • Read TXT — Take lines, or pieces between a delimiter, from a TXT file into a variable, optionally deleting them from the file.
  • Excel — Read cells from an Excel workbook on the computer, or update, append, clear, create a workbook or add a sheet.
  • Get file path — List the files in a folder, by full path, into a variable you can loop over.
  • Zip — Compress files and folders into a zip file, or extract a zip into a folder.