The OpenD Programming Language

serializeCsv

CSV serialization function.

  1. string serializeCsv(V value, char separator, char quote, bool quoteAll, string naValue, string trueValue, string falseValue, int serdeTarget)
    string
    serializeCsv
    (
    V
    )
    (
    auto scope ref const V value
    ,
    char separator = ','
    ,
    char quote = '"'
    ,
    bool quoteAll = false
    ,
    string naValue = ""
    ,
    string trueValue = "TRUE"
    ,
    string falseValue = "FALSE"
    ,)
  2. void serializeCsv(Appender appender, V value, char separator, char quote, bool quoteAll, string naValue, string trueValue, string falseValue, int serdeTarget)

Examples

import mir.timestamp: Timestamp;
import mir.format: stringBuf;
import mir.test;
auto someMatrix = [
    [3.0.CsvAlgebraic, 2.CsvAlgebraic, true.CsvAlgebraic, ],
    ["str".CsvAlgebraic, "2022-12-12".Timestamp.CsvAlgebraic, "".CsvAlgebraic, null.CsvAlgebraic],
    [double.nan.CsvAlgebraic, double.infinity.CsvAlgebraic, 0.0.CsvAlgebraic]
];

someMatrix.serializeCsv.should == "3.0,2,TRUE\nstr,2022-12-12,\"\",\nNAN,+INF,0.0\n";

Meta