/usr/local/lib/swipl/library/csv.pl
All Application Manual Name SummaryHelp

  • swipl
    • library
      • error.pl
      • debug.pl -- Print debug messages and test assertions
      • apply.pl -- Apply predicates on a list
      • lists.pl -- List Manipulation
      • broadcast.pl
      • shlib.pl
      • option.pl
      • thread_pool.pl -- Resource bounded thread management
      • gensym.pl
      • settings.pl -- Setting management
      • arithmetic.pl
      • main.pl
      • readutil.pl
      • operators.pl
      • pairs.pl
      • prolog_source.pl -- Examine Prolog source-files
      • record.pl
      • quasi_quotations.pl
      • pure_input.pl -- Pure Input from files and streams
      • solution_sequences.pl -- Modify solution sequences
      • ordsets.pl
      • random.pl
      • base64.pl
      • aggregate.pl
      • yall.pl -- Lambda expressions
      • sandbox.pl -- Sandboxed Prolog code
      • apply_macros.pl -- Goal expansion rules to avoid meta-calling
      • assoc.pl
      • prolog_format.pl
      • predicate_options.pl
      • csv.pl -- Process CSV (Comma-Separated Values) data
        • csv_read_file/2
        • csv_read_file/3
        • csv_read_stream/3
        • csv//1
        • csv//2
        • csv_read_file_row/3
        • csv_read_row/3
        • csv_options/2
        • csv_write_file/2
        • csv_write_file/3
        • csv_write_stream/3
      • pprint.pl
      • atom.pl
      • modules.pl
      • occurs.pl
      • prolog_xref.pl
      • prolog_colour.pl
      • lazy_lists.pl -- Lazy list handling
      • ugraphs.pl
      • url.pl
      • www_browser.pl -- Open a URL in the users browser
      • prolog_pack.pl
      • git.pl -- Run GIT commands
      • rbtrees.pl
      • dif.pl
      • charsio.pl
      • prolog_stack.pl
      • edinburgh.pl
      • prolog_clause.pl
      • prolog_breakpoints.pl -- Manage Prolog break-points
      • wfs.pl
      • dialect.pl
      • prolog_code.pl -- Utilities for reasoning about code
      • sort.pl
      • iostream.pl -- Utilities to deal with streams
      • dicts.pl
      • varnumbers.pl
      • fastrw.pl
      • base32.pl
      • codesio.pl
      • coinduction.pl -- Co-Logic Programming
      • date.pl -- Process dates and times
      • heaps.pl
      • statistics.pl -- Get information about resource usage
      • terms.pl
      • utf8.pl -- UTF-8 encoding/decoding on lists of character codes.
      • when.pl
      • backcomp.pl
      • threadutil.pl -- Interactive thread utilities
      • quintus.pl -- Quintus compatibility
      • prolog_trace.pl
      • prolog_wrap.pl
      • listing.pl
      • ctypes.pl
      • shell.pl -- Elementary shell commands
      • hashtable.pl
      • macros.pl
      • prolog_debug.pl
      • nb_set.pl
      • edit.pl
      • increval.pl
      • tables.pl
      • ansi_term.pl
      • prolog_jiti.pl
      • streams.pl
      • zip.pl
      • strings.pl
 csv_read_file(+File, -Rows) is det
 csv_read_file(+File, -Rows, +Options) is det
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).