Skip to main content

PARSE_CSV

Deprecated version

This document refers to a deprecated version of the RQL programming language.

Please go here for documentation related to the latest supported version.

Parse a string with CSV document.

Syntax
PARSE_CSV[type](
<string>,
delimiter := ",",
skip := 0,
escape := "\\",
quote := "\"",
nulls := [""],
nans := [],
time_format := "HH:mm[:ss[.SSS]]",
date_format := "yyyy-MM-dd",
timestamp_format := "yyyy-M-d'T'HH:mm[:ss[.SSS]]",
)

  • The <type> is the type of each row of data.
  • The optional argument delimiter specifies the delimiter to use.
  • The optional argument skip specifies the number of lines to skip in the data.
  • The optional argument escape specifies a escape character while parsing the CSV file.
  • The optional argument quote specifies the quote character in the data.
  • The optional argument time_format specifies the format to use while parsing time fields.
  • The optional argument date_format specifies the format to use while parsing date fields.
  • The optional argument timestamp_format specifies the format to use while parsing timestamp fields.
Example
data := """"a, 1.0
b, 2.0"""
PARSE_CSV[record(_1: string, _2: string)](data) // [("a", "1.0"), ("b", "2.0")]

// To parse CSV strings with a header, set skip to 1.
data := """name, age
john, 35
jane, 32""";

PARSE_CSV[record(name: string, age: int)](data, skip := 1) // [(name: "john", age: 35), (name: "jane", age: 32)]

// How to parse a string with a delimiter.
data := """name| age
john| 35
jane| 32""";

PARSE_CSV[record(name: string, age: int)](data, delimiter := "|", skip := 1) // [(name: "john", age: 35), (name: "jane", age: 32)]