Step-By-Step Guide to Use File Read to Read a .txt File and Store the Content as a JSON Fragment

Let's see an example of reading a .txt file and store the content as a JSON fragment.

 

To read the required file:

  1. Create  a new process.
  2. In the Canvas Tools pane, click File to expand the tool and view the associated activities.
  3. Drag the File Read activity and drop on to the Flowchart designer on the Canvas. The validation error symbol disappears when required inputs are provided.
  4. In the Parameter bar, create In arguments, Path and Output of type String. These arguments are used to pass the folder path as input for identifying the required file and store the output JSON fragment respectively.

 

 

  1. In the File Path list, select the Path argument created above.
  2. In the Output Json list, select the Output argument created above.
    To view the output in Automation Studio, let's add WriteLine activity. You can publish, deploy and assign this process to a robot if you want to execute the process outside Automation Studio.
  3. Add a WriteLine activity and in the Text field, select the Output parameter created above to store the result of search operation performed. Below is the sample automation process workflow created:

 

 

  1. Save the process.
  2. Setup the environment and then perform test run. Below is the sample JSON fragment displayed in the Output console:

 

 

You can use the JSON activity to extract a relevant part of the response as per your requirement.