Skip to content

Read CSV

Type: read-csv  ·  Package: CSV Activities v1.0.5  ·  Output: DataTable

Reads a CSV file and returns its content as a DataTable, ready to loop over, filter or write to another destination.

Reads the file at path using the given delimiter. By default it takes the first row as headers (hasHeader = true), so you access cells by name.

  • Columns: with hasHeader = true, names come from the first non-blank line (trimmed); an empty header cell gets an automatic name (Column1, Column2…). With hasHeader = false, columns are named Column1, Column2… and the first line is just another data row.
  • Column count: set by the first line. If a row has more fields, the extra ones are dropped; if it has fewer, the missing cells stay empty (DBNull).
  • Values: all text, without their surrounding quotes. Spaces around a value are kept.
  • Blank lines: ignored.
  • One line per record: a quoted field containing line breaks splits the record; if your file has them, open it with Excel instead.
  • All in memory: it loads the whole file. It only reads; the file is not changed.
ParameterTypeDefaultDescription
pathstring—Path of the CSV file.
ParameterTypeDefaultDescription
delimiterstring","Field separator. Only the first character is used: ",", ";", "|"… For a tab, ((char)9).ToString().
hasHeaderbooltrueThe first row holds the column names.
encodingstring"utf-8"File encoding: utf-8, iso-8859-1, utf-16… If the file has a BOM, the BOM wins. See encoding.

Returns a DataTable:

  • Columns: text columns named after the header (or Column1, Column2… without a header).
  • Rows: one per data line. Read each cell with str(row["Name"]), which turns empty cells into "".
  • Empty file (or only blank lines): a DataTable with no columns and no rows. Check it with rowCount(table) == 0.
MessageCause and fix
File not found.path does not exist. Check it with File Exists.
A column named '…' already belongs to this DataTable.Two header columns share the same name. Fix the file, or read with hasHeader = false and use Column1, Column2…
Index was outside the bounds of the array.delimiter is empty. Give a character.
The process cannot access the file '…' because it is being used by another process.The file is open in another program (for example Excel). Close it first.
'path' is required.The path expression evaluated to null.
Read CSV path = asset("customers.csv") delimiter = ";" → output: customers
Log message = "Customers read: " + rowCount(customers)
For Each items = customers itemVariable = row
└─ activities:
Log message = str(row["Name"]) + " — " + str(row["Email"])