Skip to content

Parse CSV

Parses CSV bytes into a row dataset handle.

@lainstack/csv/parse · Data

Parse CSV reads one uploaded or stored CSV file and writes its rows to a run-scoped Table handle under rows. The rows are not inline in the output. previewRows holds only the first 20 rows. summary.rowCount and summary.byteCount are plain numbers.

To use the rows:

  • Loop over them with @lainstack/flow/for-each-item.
  • Load a small set into an array with @lainstack/collection/load-array.
  • Load them into a Reference Table with @lainstack/reference-table/write.

Choose @lainstack/data/parse-json instead when the input is JSON text.

Traps:

  • Column types are inferred from the first 100 data rows: number, boolean (true, false, yes, no), ISO date, or text. A later row that breaks the inferred type fails the whole step.
  • A column whose values include a number with a leading zero, like 01234, stays text. Empty cells become null.
  • Column ids are column-1, column-2 and so on, in header order. Duplicate header names get a numeric suffix.
  • The first row must be a header. Every row must have the same number of fields as the header, or the step fails.
  • The file must be at most 50 MiB and 500,000 rows. An upload field must hold exactly one file.
Setting Key Type Details
CSV file (required) csv Value
Output Path Type
Source file sourceRef Value
Table rows rows Value
Row count summary.rowCount Number
Byte count summary.byteCount Number