A.11 library(csv): Process CSV (Comma-Separated Values) data
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(csv): 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
    • Packages
Availability::- use_module(library(csv)).(can be autoloaded)
Source[det]csv_write_stream(+Stream, +Data, +Options)
Write the rows in Data to Stream. This is similar to csv_write_file/3, but can deal with data that is produced incrementally. The example below saves all answers from the predicate data/3 to File.
save_data(File) :-
   setup_call_cleanup(
       open(File, write, Out),
       forall(data(C1,C2,C3),
              csv_write_stream(Out, [row(C1,C2,C3)], [])),
       close(Out)).