Read a CSV file into a list of rows. Each row is a Prolog term
with the same arity. Options is handed to csv//2. Remaining
options are processed by phrase_from_file/3. The default
separator depends on the file name extension and is \t
for
.tsv
files and ,
otherwise.
Suppose we want to create a predicate table/6 from a CSV file
that we know contains 6 fields per record. This can be done
using the code below. Without the option arity(6)
, this would
generate a predicate table/N, where N is the number of fields
per record in the data.
?- csv_read_file(File, Rows, [functor(table), arity(6)]),
maplist(assert, Rows).