How to read and write files inside a folder
Examples with the File Reader and File Writer components.
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'.


- 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
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'.


- 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
Last modified 2mo ago