All Collections
Components
Files
How to read and write files inside a folder
How to read and write files inside a folder

Examples with the File Reader and File Writer components.

Micaella Mazoni avatar
Written by Micaella Mazoni
Updated over a week ago

Supported Usage Scenarios

Scenario 1: Read a file inside a folder
Let's say you have a file named 'file.txt' inside 'folder', available in your pipeline.
To read this file inside a folder, you may invoke a File Reader that indicates the path 'folder/file.txt'. That way, you can access the file 'file.txt'.

Example:

  1. Create a pipeline and add a File Reader

  2. Open the component settings

  3. Define the FILE NAME as 'folder/file.txt'

  4. Click on CONFIRM to save the component settings

  5. Connect the trigger with File Reader

  6. Run a test in the pipeline (CTRL + ENTER)

The result will be shown:

{
  "data": [
    "my sample content"
  ],
  "fileName": "folder/file.txt",
  "lineCount": 1
}

  • data: array with the content of the file read by File Reader

  • fileName: shows the complete path of the read file

  • lineCount: identifies the amount of lines within the file read by File Reader


Scenario 2: Write a file inside a folder
Let's say you have a file named 'file.txt' inside 'folder', available in your pipeline.
To write this file inside a folder, you may invoke a File Reader that indicates the path 'folder/file.txt'. That way, you can access the file 'file.txt'.

Example:

  1. Create a pipeline and add a File Reader

  2. Open the component settings

  3. Define the FILE NAME as 'folder/file.txt'

  4. Define the field DATA as {{ message.data }}.
    Mind we're using the Double Braces expression: {{ message.data }} to access the result of the last component. In this case, we access data with the content of the file to be written.

  5. Click on CONFIRM to save the component settings

  6. Connect the Trigger with the File Reader

  7. Run a test in the pipeline (CTRL + ENTER)

The result will be shown:

{
 "fileName": "folder/file.txt",
 "success": true
}

  • fileName: shows the complete path of the written file

  • success: when the result is true, it indicates that the execution was successful

Lots of other components have the features above:

  • Read and Write files
    File Reader
    File Writer
    CSV File Writer
    CSV to Excel
    Excel
    Stream Excel
    Stream File Reader V2

  • Upload, Download and Data Storage Files Delete
    Digibee Storage
    S3 Storage
    Google Storage
    Dropbox
    SFTP
    FTP
    One Drive
    WebDAV

  • Other components
    WGet
    Zip File
    REST V2
    PGP

Did this answer your question?