[ library(csv) | Reference Manual | Alphabetic Index ]

# csv_read_row(+Stream, -Row, +Options)

Read a line containing comma separated values (csv format)

Stream
  Input stream
Row
  List or structure (output)
Options
  List of options, or cvs_options-structure

## Description

Reads a single row from Stream containing comma separated values.

By default, the result is a list containing the row's field values. Alternatively, the type-option can be used to return a structure instead of list.

For other details see csv_read/3.

If csv_read_row/3 is called numerous times with complex options, the option list should be precompiled using csv_options/2, and the resulting structure passed as Options argument.

### Modes and Determinism

- csv_read_row(+, -, +) is det

## Examples

        % Given file data.csv containing the line:
        % a, b, 123, c d," e f "
        % 99, aa, bb, 123, C d

        ?- open("data.csv", read, S),
           csv_read_row(S, Row1, []),
           csv_read_row(S, Row2, []).
        Row1 = ["a", " b", 123, " c d", " e f "]
        Row2 = [99, " aa", " bb", 123, " C d"]

        ?- open("data.csv", read, S),
           csv_options(Options, [strip:true, type:row/_]),
           csv_read_row(S, Row1, Options),
           csv_read_row(S, Row2, Options).
        Row1 = row("a", "b", 123, "c d", "e f")
        Row2 = row(99, "aa", "bb", 123, "C d")

## See Also

csv_read / 3, csv_options / 2