The Open action lets you choose the delimiter that you must use in the file, remove the spaces from the file, and set the correct encoding for the file.

Note:
  • If a double quotation mark (") is the last element of the last line of the CSV/TXT file, the bot encounters an error during runtime.
  • When you use the CSV/TXT > Open action to open a CSV file, read it, and assign it to a table, then write it to a file using the Data table > Write to file action, the automation interprets any commas in the header or cell data as delimiters. For instance, if three consecutive cells contain data like "abc", "bcd", "efd", the final output will enclose each in triple double quotes, resulting in """abc""", """bcd""", """efd""".
Once you create a bot, perform the following steps to open a CSV or text file using the Open action.

Procedure

  1. Double-click or drag the Open action from the CSV/TXT package in the Actions palette.
  2. Select any of the following options to specify the location of the CSV or text file to open:
    • Control Room 文件: 允许您从 Control Room 打开文件。
    • 桌面文件: 允许您从设备打开文件。 此字段还接受作为字符串变量或全局值的文件路径输入。
      Note: 当您在桌面文件字段中输入文件路径或从系统中浏览特定文件时,其中文件路径由 \ 字符分隔,保存 bot 时,\ 字符会变更为 /,因为 bot 使用 / 分隔文件路径。 即使在 bot 执行期间将 \ 更改为 /,bots 仍能成功运行。
    • 变量: 允许您通过指定文件变量打开文件。
    Open action supports file streaming. You can map a file from any cloud storage to a file variable and use the variable as a data source. You can use one of the supported actions to create a streamable file variable.
  3. Enable the Contains header check box if the file contains a header row and you want to retrieve values from that row.
  4. Select any of the following options to specify the Delimiter used in the file:
    • Comma
    • Tab
    • Regional list separator: Enables you to specify the delimiter as configured in the regional settings of the Windows operating system. If the List Separator in the Windows regional settings is modified, then the CSV file should also contain that character as a delimiter.
    • Newline
    • Other: Enables you to specify a delimiter other than the options listed above.
  5. Select the Trim leading spaces and Trim trailing spaces check boxes to remove the leading and trailing spaces from the data extracted from the CSV/TXT file.
  6. Select an option from the Encoding list to specify the encoding that is applied on the file. Data from the CSV/TXT file will be retrieved based on the selected encoding option even if the input file has a different encoding.
    • ANSI: 用于编码拉丁字母。
    • UTF8: 能够对所有可能的字符进行编码。
    • UNICODE
    • Win1251: used to encode languages that use the Cyrillic script, including Bulgarian, Russian, and Serbian.
    • UTF-16LE: ignores the byte order mark (BOM) Unicode character at the beginning of file.
    • Default: identifies file encoding. This option supports UTF-8, UTF-16LE, and UTF-16BE file encoding.
    Note: Shift-JIS files must use ANSI as encoding to read text file content.
  7. Click Save.

Next steps

Use the Read action to retrieve the data from CSV/TXT file and assign them to a table variable. You can use the loop action to retrieve each row of data from the file or table variable and assign them to the record variable for further operations.