xk6-csv enables k6 tests to comfortably parse CSV values.
Import an entire module's contents:
import * as CSV from "k6/x/csv";
Import a single export from a module:
import { parse } from "k6/x/csv";
▸ parse(text
: string, separator?
: string): object[]
The parse() method parses a CSV string, constructing the JavaScript array objects described by the string. The first line of CSV file must be the header with field names. The returned array will contains objects corresponding to CSV lines, one object per line, with field names as property names and field values as property values.
Name | Type | Description |
---|---|---|
text |
string | The string to parse as CSV |
separator? |
string | The field separator character, must be one character string if present. Default is comma (, ) |
Returns: object[]
The array of objects corresponding to the given CSV text.