Read CSV File

Verb: readCSV

Available from: <Standard>

Reads a CSV file using the specified delimiter. It returns its contents in a data table and the number of existing rows and columns.

Comma Separated Values (CSV) is a file format that stores tabulated data, taking up much less space than conventional tables.


readCSV --filepath(String) --delimiter(String) --hasheaders(Boolean) [--encoding(Nullable<EncodingType>)] [--missingfieldaction(MissingFieldAction)] (DataTable)=value (Numeric)=rows (Numeric)=columns


Script Designer Required AcceptedTypes Description
--filepath File Required Text Full path of the ".csv" file.
--delimiter Delimiter Required Text Character that delimits each information stored in the data table.
Most commonly used characters are comma “,” and semicolon “;”, but you can use another custom character.
--hasheaders Has Headers Required Boolean When enabled, interprets the table's first line as a header.
--encoding Encoding Optional EncodingType Type of encoding of the characters used. Options:
  • Automatic
  • Big Endian Unicode
  • Operating System Default
  • Unicode
  • UTF32
  • UTF7
  • UTF8
  • --missingfieldaction Missing Field Action Optional MissingFieldAction Options for action to take when there is an empty field in the file:
  • Parse Error: Used when there is a need to check file integrity because it stops execution when one of the lines does not match the expected number of columns;
  • Replace By Empty: Used to disregard the missing field of the file and replace it with an empty value that has an address in memory;
  • Replace By Null: Used to disregard the missing field of the file and replace it with a null field that has no reference in memory.
  • Outputs

    Script Designer AcceptedTypes Description
    value Data Table Data Table Returns the data table with the content.
    rows Rows Number Number of table rows.
    columns Columns Number Number of table columns.


    The command reads the file ".csv" and returns the contents of the file in the variable "fileDataTable" as a data table. In the variables "fileRows" and "fileColumns", returns the number of rows and columns of the table, respectively, using the comma "," as delimiter.

    defVar --name fileDataTable --type DataTable
    defVar --name fileRows --type Numeric
    defVar --name fileColumns --type Numeric
    // Download the following file to execute the command.
    readCSV --filepath "readCSVExample.csv" --delimiter "," --hasheaders  --encoding "Default" --missingfieldaction "ReplaceByEmpty" fileDataTable=value fileRows=rows fileColumns=columns
    logMessage --message "Data Table: ${fileDataTable}\r\nNumber of Columns: ${fileColumns}\r\n// Number of Rows: ${fileRows}\r\n" --type "Info"
    // Output in console:
    // Data Table: Client, IBM Robotic Process Automation, 2019;
    // Employee, IBM Robotic Process Automation, 2018;
    // PO, IBM Robotic Process Automation, 2015;
    // Number of Columns: 3;
    // Number of Rows: 3.

    Download File

    For the script to work properly, it is necessary to download the file and enter its path in the File parameter of the Read CSV File command.