![]() |
|
Navigation |
Synopsis Write a relation to a CSV (Comma Separated Values) file.
Function
Usage
import lang::csv::IO;
Description Write
relation to a CSV file at location .
The options influence the way the actrual CSV file is written:
Examples
rascal>import lang::csv::IO; ok rascal>rel[int position, str artist, str title, int year] R1 = { >>>>>>> <1,"Eagles","Hotel California",1977>, >>>>>>> <2,"Queen","Bohemian rhapsody",1975>, >>>>>>> <3,"Boudewijn de Groot","Avond",1997> >>>>>>>}; rel[int position,str artist,str title,int year]: { <1,"Eagles","Hotel California",1977>, <3,"Boudewijn de Groot","Avond",1997>, <2,"Queen","Bohemian rhapsody",1975> } rascal>writeCSV(R1, |courses:///Rascal/Libraries/lang/csv/ex1a.csv|); ok rascal>writeCSV(R1, |courses:///Rascal/Libraries/lang/csv/ex1b.csv|, header = false, separator = ";"); okwill produce the following files: ex1a.csv (with a header line and default separator , ):
position,artist,title,year 1,Eagles,Hotel California,1977 3,Boudewijn de Groot,Avond,1997 2,Queen,Bohemian rhapsody,1975 ex1b.csv (without a header line with separator ; ):
1;Eagles;Hotel California;1977 3;Boudewijn de Groot;Avond;1997 2;Queen;Bohemian rhapsody;1975 ![]() |