Previous Topic: Output ParametersNext Topic: Rename File Operator


Example (Read from File Operator)

This example lets you read from a file named ReadFile.txt. The file content is as follows:

This example considers the following scenarios:

Follow these steps:

  1. Design a process with the Read from File operator as shown in the following illustration:

  2. Double-click the Read from File operator to open the Read from File properties, and select the Read file into Dataset Variable panel.

    To read from the file

  3. Enter the following file path in the Source File Name.

    (Windows) C:\\ReadFile.txt

    (UNIX) /root/readfromfile.txt

  4. Run the process.
  5. Open the Operation Results to view the DatasetVariable value as shown in the following illustration:

    To read from file and save the file content as an array

  6. Select the Return file contents in a string array check box.

    The file content is available as an array as shown in the following illustration:

    To read specific lines in the file

  7. Enter 1 in the From Line Number file to read form the line one from the ReadFile.txt file.
  8. Enter 4 in the To Line Number to read until the fourth line in the ReadFile.txtfile.

    The file content is read and saved in the dataset form line 1 through 4 as shown in the following illustration:

    To read the file and save the file content in a dataset variable

  9. Enter DataRead as Dataset Variable Name.

    The file content is saved in the DataRead dataset and not in the system dataset as shown in the following illustration:

You can also specify the User ID and password of the user account to grant execute permission on a process. When you provide User ID and password values at the operator level you override the values that are defined in the Require user credentials field. You define the Require user credentials field in File Management properties.

Note: Ensure that you grant Read permission to the user and Read and Execute permissions to the PAM installation directory to run the ReadFile service operation. For more information about how to configure file management, see the Configure File Management section in the Content Administrator Guide.