github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/types/csv/csv.go (about)

     1  package csv
     2  
     3  import (
     4  	"github.com/lmorg/murex/config"
     5  	"github.com/lmorg/murex/lang"
     6  	"github.com/lmorg/murex/lang/stdio"
     7  	"github.com/lmorg/murex/lang/types"
     8  )
     9  
    10  const typeName = "csv"
    11  
    12  func init() {
    13  	//stdio.RegisterReadArray(typeName, readArray)
    14  	stdio.RegisterReadMap(typeName, readMap)
    15  
    16  	lang.ReadIndexes[typeName] = readIndex
    17  	lang.ReadNotIndexes[typeName] = readIndex
    18  
    19  	lang.Marshallers[typeName] = marshal
    20  	lang.Unmarshallers[typeName] = unmarshal
    21  
    22  	// `application/csv` and `text/csv` are the common ones. `x-csv` is added just in case anyone decides to use
    23  	// something non-standard.
    24  	lang.SetMime(typeName,
    25  		"application/csv",
    26  		"application/x-csv",
    27  		"text/csv",
    28  		"text/x-csv",
    29  	)
    30  
    31  	lang.SetFileExtensions(typeName, "csv")
    32  
    33  	config.InitConf.Define("csv", "separator", config.Properties{
    34  		Description: "The delimiter for records in a CSV file.",
    35  		Default:     `,`,
    36  		DataType:    types.String,
    37  	})
    38  
    39  	config.InitConf.Define("csv", "comment", config.Properties{
    40  		Description: "The prefix token for comments in a CSV table.",
    41  		Default:     `#`,
    42  		DataType:    types.String,
    43  	})
    44  }