CSVDialect

Inherits: RefCounted < Object

Reusable CSV parsing profile.

Description

CSVDialect stores delimiter, header, casting, and parser option settings for common CSV variants. It can be created from built-in profiles, dictionaries, or inferred from a sample string.

Properties

bool

cast_fields

true

String

delimiter

","

bool

headers

false

Dictionary

options

{}

Methods

CSVDialect

from_dictionary(data: Dictionary) static

CSVDialect

from_profile(name: String) static

Array

import_file(path: String) const

Array

import_string(string: String) const

CSVDialect

sniff(sample: String, options: Dictionary = {}) static

Dictionary

to_dictionary() const


Property Descriptions

bool cast_fields = true 🔗

  • void set_cast_fields(value: bool)

  • bool get_cast_fields()

If true, imported values are converted to typed values.


String delimiter = "," 🔗

The delimiter used to split fields.


bool headers = false 🔗

  • void set_headers(value: bool)

  • bool get_headers()

If true, the first row is treated as headers.


Dictionary options = {} 🔗

Parser options used by this dialect.


Method Descriptions

CSVDialect from_dictionary(data: Dictionary) static 🔗

Creates a dialect from a dictionary produced by to_dictionary().


CSVDialect from_profile(name: String) static 🔗

Creates a built-in dialect profile. Supported names include csv, rfc4180, tsv, excel, and pipes.


Array import_file(path: String) const 🔗

Imports path using this dialect.


Array import_string(string: String) const 🔗

Imports string using this dialect.


CSVDialect sniff(sample: String, options: Dictionary = {}) static 🔗

Infers a dialect from sample.


Dictionary to_dictionary() const 🔗

Serializes this dialect to a dictionary.