to_csv()

Search
Feedback

Usage

to_csv(nodes, propertiesOrView[, delimiterChar = ';' [, quoteChar = '"' [, recordSeparator = "\n" [, includeHeader = true[, localizeHeader = false [, headerLocalizationDomain]]]])

Description
Returns a CSV string representation of the given collection of objects.

Parameters

  • nodes: A collection of objects
  • propertiesOrView: The name of a view (e.g. ui or public) or a collection of property names (e.g. merge('id', 'name') in StructrScript or ['id', 'name'] in JavaScript)
  • delimiterChar (default: ;): A single character used as the column separator. (If more than one character is supplied, only the first character is used without raising an error)
  • quoteChar (default: "): A single character used as the quote character. (If more than one character is supplied, only the first character is used without raising an error)
  • recordSeparator (default: \n): The separator between the records (recommended usage is \n, \r or \r\n)
  • includeHeader (default true): Switch indicating if a header row should be printed
  • localizeHeader (default false): Switch indicating if the column names in the header should be localized
  • headerLocalizationDomain: Optional header localization domain

Note

  • If the column values contain the quote character, a \ is prepended before that instance of the quote character
  • All instances of \n or \r in the column values are replaced by \\n and \\r respectively so we can guarantee that only intended newlines (i.e. the record separator) occurr inside the produced CSV

Example

${to_csv(find('User'), 'public')}
${to_csv(find('User'), merge('id', 'name'))}

results in

"id";"type";"name";"isUser"
"70fd9f831cad4506a1076f956ffa2a0b";"User";"admin";"true"

"id";"name"
"70fd9f831cad4506a1076f956ffa2a0b";"admin"

Graph-Browser

Related Articles
About this article
Last change 2017-07-13
Topics