Skip to main content

decode_copy_csv_record

Function decode_copy_csv_record 

Source
pub fn decode_copy_csv_record(
    record: &str,
    delimiter: char,
    quote: char,
    null_str: &str,
) -> Vec<Option<String>>
Expand description

Decode one CSV data record (COPY … FROM stdin WITH (FORMAT csv)) into its fields. A field that starts with the quote character is a quoted field: its content runs to the matching close quote, a doubled quote ("") is one literal quote, and it is never NULL — a quoted empty string stays Some(""). An unquoted field runs to the next delimiter; if its text equals null_str it decodes to NULL, so with the default empty null string an empty unquoted field is NULL while "" is the empty string (PG’s exact CSV distinction). Embedded delimiters and newlines are only meaningful inside quotes.