<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>csv on Grafana Labs</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/</link><description>Recent content in csv on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/index.xml" rel="self" type="application/rss+xml"/><item><title>parse( file, [options] )</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/parse/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/parse/</guid><content><![CDATA[&lt;h1 id=&#34;parse-file-options-&#34;&gt;parse( file, [options] )&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;csv.parse&lt;/code&gt; function parses an entire CSV file at once and returns a promise that resolves to a 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-data/sharedarray/&#34;&gt;SharedArray&lt;/a&gt; instance.
This function uses Go-based processing, which results in faster parsing and lower memory usage compared to JavaScript alternatives.
It&amp;rsquo;s ideal for scenarios where performance is a priority, and the entire CSV file can be loaded into memory.&lt;/p&gt;
&lt;h2 id=&#34;parameters&#34;&gt;Parameters&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Parameter&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;file&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/&#34;&gt;fs.File&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;A file instance opened using the &lt;code&gt;fs.open&lt;/code&gt; function.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;options&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/options/&#34;&gt;Options&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;An optional parameter object to customize the parsing behavior.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;returns&#34;&gt;Returns&lt;/h2&gt;
&lt;p&gt;A promise resolving to a 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-data/sharedarray/&#34;&gt;SharedArray&lt;/a&gt; instance, where each element is an array representing a CSV record, and each sub-element is a field from that record.&lt;/p&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;h3 id=&#34;basic-usage&#34;&gt;Basic Usage&lt;/h3&gt;
&lt;!--md-k6:skip--&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { open } from &amp;#39;k6/experimental/fs&amp;#39;;
import csv from &amp;#39;k6/experimental/csv&amp;#39;;
import { scenario } from &amp;#39;k6/execution&amp;#39;;

export const options = {
  iterations: 10,
};

const file = await open(&amp;#39;data.csv&amp;#39;);

// The `csv.parse` function consumes the entire file at once and returns
// the parsed records as a `SharedArray` object.
const csvRecords = await csv.parse(file);

export default async function () {
  // `csvRecords` is a `SharedArray`. Each element is a record from the CSV file, represented as an array
  // where each element is a field from the CSV record.
  //
  // `csvRecords[scenario.iterationInTest]` gives the record for the current iteration.
  console.log(csvRecords[scenario.iterationInTest]);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;using-asobjects&#34;&gt;Using &lt;code&gt;asObjects&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;asObjects&lt;/code&gt; option parses the CSV file into an array of objects. The object keys are the column names from the CSV file, and the values are the field values from the CSV record.
Note that the first line of the CSV file is skipped, as it is assumed to contain the column names (header row).&lt;/p&gt;
&lt;!--md-k6:skip--&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { open } from &amp;#39;k6/experimental/fs&amp;#39;;
import csv from &amp;#39;k6/experimental/csv&amp;#39;;
import { scenario } from &amp;#39;k6/execution&amp;#39;;

export const options = {
  iterations: 3,
};

const file = await open(&amp;#39;data.csv&amp;#39;);
const csvRecords = await csv.parse(file, { asObjects: true });

export default function () {
  // Will print the record for the current iteration as an object.
  //
  // For example, given the following CSV file:
  //
  // firstname,lastname
  // francois,mitterand
  // helmut,kohl
  // pierre,mendes-france
  //
  // The test will print:
  //
  // { firstname: &amp;#39;francois&amp;#39;, lastname: &amp;#39;mitterand&amp;#39; }
  // { firstname: &amp;#39;helmut&amp;#39;, lastname: &amp;#39;kohl&amp;#39; }
  // { firstname: &amp;#39;pierre&amp;#39;, lastname: &amp;#39;mendes-france&amp;#39; }
  console.log(csvRecords[scenario.iterationInTest]);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;notes-on-usage&#34;&gt;Notes on Usage&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Memory considerations&lt;/strong&gt;: &lt;code&gt;csv.parse&lt;/code&gt; loads the entire CSV file into memory at once, which may lead to increased memory usage and startup time for very large files.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shared memory usage&lt;/strong&gt;: The 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-data/sharedarray/&#34;&gt;SharedArray&lt;/a&gt; returned by &lt;code&gt;csv.parse&lt;/code&gt; is shared among all Virtual Users (VUs), reducing memory overhead when multiple VUs access the same data.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="parse-file-options-">parse( file, [options] )&lt;/h1>
&lt;p>The &lt;code>csv.parse&lt;/code> function parses an entire CSV file at once and returns a promise that resolves to a
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-data/sharedarray/">SharedArray&lt;/a> instance.
This function uses Go-based processing, which results in faster parsing and lower memory usage compared to JavaScript alternatives.
It&amp;rsquo;s ideal for scenarios where performance is a priority, and the entire CSV file can be loaded into memory.&lt;/p></description></item><item><title>Parser</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/parser/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/parser/</guid><content><![CDATA[&lt;h1 id=&#34;parser&#34;&gt;Parser&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;csv.Parser&lt;/code&gt; class provides a streaming parser that reads CSV files line-by-line, offering fine-grained control over the parsing process and minimizing memory consumption.
It&amp;rsquo;s well-suited for scenarios where memory efficiency is crucial or when you need to process large CSV files without loading the entire file into memory.&lt;/p&gt;
&lt;h2 id=&#34;constructor&#34;&gt;Constructor&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Parameter&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;file&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/file/&#34;&gt;fs.File&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;A file instance opened using the fs.open function.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;options&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/fs/options/&#34;&gt;Options&lt;/a&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;An optional parameter object to customize the parsing behavior. Options can include a delimiter (string).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;methods&#34;&gt;Methods&lt;/h3&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Name&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;&lt;code&gt;next()&lt;/code&gt;&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Reads the next line from the CSV file and returns a promise that resolves to an iterator-like object.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;returns&#34;&gt;Returns&lt;/h3&gt;
&lt;p&gt;A promise resolving to an object with the following properties:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Property&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;done&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;boolean&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Indicates whether there are more rows to read (false) or the end of the file has been reached (true).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;value&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string[]&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Contains the fields of the CSV record as an array of strings. If done is true, value is undefined.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;
&lt;h3 id=&#34;basic-usage&#34;&gt;Basic Usage&lt;/h3&gt;
&lt;!--md-k6:skip--&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { open } from &amp;#39;k6/experimental/fs&amp;#39;;
import csv from &amp;#39;k6/experimental/csv&amp;#39;;

export const options = {
  iterations: 10,
};

const file = await open(&amp;#39;data.csv&amp;#39;);
const parser = new csv.Parser(file, { skipFirstLine: true });

export default async function () {
  // The `next` method attempts to read the next row from the CSV file.
  //
  // It returns an iterator-like object with a `done` property that indicates whether
  // there are more rows to read, and a `value` property that contains the row fields
  // as an array.
  const { done, value } = await parser.next();
  if (done) {
    throw new Error(&amp;#39;No more rows to read&amp;#39;);
  }

  // We expect the `value` property to be an array of strings, where each string is a field
  // from the CSV record.
  console.log(done, value);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;using-asobjects&#34;&gt;Using &lt;code&gt;asObjects&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;asObjects&lt;/code&gt; option parses the CSV file into an array of objects. The object keys are the column names from the CSV file, and the values are the field values from the CSV record.
Note that the first line of the CSV file is skipped, as it is assumed to contain the column names (header row).&lt;/p&gt;
&lt;!--md-k6:skip--&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { open } from &amp;#39;k6/experimental/fs&amp;#39;;
import csv from &amp;#39;k6/experimental/csv&amp;#39;;
import { scenario } from &amp;#39;k6/execution&amp;#39;;

export const options = {
  iterations: 3,
};

const file = await open(&amp;#39;data.csv&amp;#39;);
const parser = new csv.Parser(file, { asObjects: true });

export default async function () {
  // Will print the record for the current iteration as an object.
  //
  // For example, given the following CSV file:
  //
  // firstname,lastname
  // francois,mitterand
  // helmut,kohl
  // pierre,mendes-france
  //
  // The test will print:
  //
  // { firstname: &amp;#39;francois&amp;#39;, lastname: &amp;#39;mitterand&amp;#39; }
  // { firstname: &amp;#39;helmut&amp;#39;, lastname: &amp;#39;kohl&amp;#39; }
  // { firstname: &amp;#39;pierre&amp;#39;, lastname: &amp;#39;mendes-france&amp;#39; }
  const { done, value } = await parser.next();
  if (done) {
    throw new Error(&amp;#39;No more rows to read&amp;#39;);
  }

  console.log(value);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;notes-on-usage&#34;&gt;Notes on usage&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Memory efficiency&lt;/strong&gt;: Since &lt;code&gt;csv.Parser&lt;/code&gt; reads the file line-by-line, it keeps memory usage low and avoids loading the entire set of records into memory. This is particularly useful for large CSV files.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Streaming control&lt;/strong&gt;: The streaming approach provides more control over how records are processed, which can be beneficial for complex data handling requirements.&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="parser">Parser&lt;/h1>
&lt;p>The &lt;code>csv.Parser&lt;/code> class provides a streaming parser that reads CSV files line-by-line, offering fine-grained control over the parsing process and minimizing memory consumption.
It&amp;rsquo;s well-suited for scenarios where memory efficiency is crucial or when you need to process large CSV files without loading the entire file into memory.&lt;/p></description></item><item><title>Options</title><link>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/options/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/options/</guid><content><![CDATA[&lt;h1 id=&#34;options&#34;&gt;Options&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;Options&lt;/code&gt; object describes the configuration available for the operation of parsing CSV files using the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/parse/&#34;&gt;&lt;code&gt;csv.parse&lt;/code&gt;&lt;/a&gt; function and the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/parser/&#34;&gt;&lt;code&gt;csv.Parser&lt;/code&gt;&lt;/a&gt; class.&lt;/p&gt;
&lt;h2 id=&#34;properties&#34;&gt;Properties&lt;/h2&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Property&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Type&lt;/th&gt;
              &lt;th style=&#34;text-align: left&#34;&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;delimiter&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;string&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The character used to separate fields in the CSV file. Default is &lt;code&gt;&#39;,&#39;&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;asObjects&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;boolean&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Whether to parse the CSV file&amp;rsquo;s lines as JavaScript objects. If it is &lt;code&gt;false&lt;/code&gt;, then they are parsed as arrays. Default is &lt;code&gt;false&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;skipFirstLine&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;boolean&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;Whether to skip the first line of the CSV file. Default is &lt;code&gt;false&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;fromLine&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;(optional) number&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The line number from which to start reading the CSV file. Default is &lt;code&gt;0&lt;/code&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;toLine&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;(optional) number&lt;/td&gt;
              &lt;td style=&#34;text-align: left&#34;&gt;The line number at which to stop reading the CSV file. If the option is not set, then read until the end.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;asobjects&#34;&gt;asObjects&lt;/h3&gt;
&lt;p&gt;When &lt;code&gt;asObjects&lt;/code&gt; is set to &lt;code&gt;true&lt;/code&gt;, parsing operations over the CSV file will return an array of objects. The object keys are the column names from the CSV file, as inferred from the first line of the file, and the values are the field values from the CSV record. Note that the first line of the CSV file is skipped, as it is assumed to contain the column names (header row).&lt;/p&gt;
&lt;p&gt;As a result, the following CSV file:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;csv&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-csv&#34;&gt;name,age
John,30
Jane,25&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Will be parsed into the following array of objects:&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JSON&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-json&#34;&gt;[
  { &amp;#34;name&amp;#34;: &amp;#34;John&amp;#34;, &amp;#34;age&amp;#34;: &amp;#34;30&amp;#34; },
  { &amp;#34;name&amp;#34;: &amp;#34;Jane&amp;#34;, &amp;#34;age&amp;#34;: &amp;#34;25&amp;#34; }
]&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;
&lt;!--md-k6:skip--&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { open } from &amp;#39;k6/experimental/fs&amp;#39;;
import csv from &amp;#39;k6/experimental/csv&amp;#39;;

const file = await open(&amp;#39;data.csv&amp;#39;);
const parser = new csv.Parser(file, {
  delimiter: &amp;#39;,&amp;#39;,
  skipFirstLine: true,
  fromLine: 2,
  toLine: 8,
});

export default async function () {
  // The `next` method attempts to read the next row from the CSV file.
  //
  // It returns an iterator-like object with a `done` property that indicates whether
  // there are more rows to read, and a `value` property that contains the row fields
  // as an array.
  const { done, value } = await parser.next();
  if (done) {
    throw new Error(&amp;#39;No more rows to read&amp;#39;);
  }

  // We expect the `value` property to be an array of strings, where each string is a field
  // from the CSV record.
  console.log(done, value);
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="options">Options&lt;/h1>
&lt;p>The &lt;code>Options&lt;/code> object describes the configuration available for the operation of parsing CSV files using the
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/parse/">&lt;code>csv.parse&lt;/code>&lt;/a> function and the
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-experimental/csv/parser/">&lt;code>csv.Parser&lt;/code>&lt;/a> class.&lt;/p>
&lt;h2 id="properties">Properties&lt;/h2>
&lt;section class="expand-table-wrapper">&lt;div class="button-div">
&lt;button class="expand-table-btn">Expand table&lt;/button>
&lt;/div>&lt;div class="responsive-table-wrapper">
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: left">Property&lt;/th>
&lt;th style="text-align: left">Type&lt;/th>
&lt;th style="text-align: left">Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: left">delimiter&lt;/td>
&lt;td style="text-align: left">string&lt;/td>
&lt;td style="text-align: left">The character used to separate fields in the CSV file. Default is &lt;code>','&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">asObjects&lt;/td>
&lt;td style="text-align: left">boolean&lt;/td>
&lt;td style="text-align: left">Whether to parse the CSV file&amp;rsquo;s lines as JavaScript objects. If it is &lt;code>false&lt;/code>, then they are parsed as arrays. Default is &lt;code>false&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">skipFirstLine&lt;/td>
&lt;td style="text-align: left">boolean&lt;/td>
&lt;td style="text-align: left">Whether to skip the first line of the CSV file. Default is &lt;code>false&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">fromLine&lt;/td>
&lt;td style="text-align: left">(optional) number&lt;/td>
&lt;td style="text-align: left">The line number from which to start reading the CSV file. Default is &lt;code>0&lt;/code>.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">toLine&lt;/td>
&lt;td style="text-align: left">(optional) number&lt;/td>
&lt;td style="text-align: left">The line number at which to stop reading the CSV file. If the option is not set, then read until the end.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;/section>&lt;h3 id="asobjects">asObjects&lt;/h3>
&lt;p>When &lt;code>asObjects&lt;/code> is set to &lt;code>true&lt;/code>, parsing operations over the CSV file will return an array of objects. The object keys are the column names from the CSV file, as inferred from the first line of the file, and the values are the field values from the CSV record. Note that the first line of the CSV file is skipped, as it is assumed to contain the column names (header row).&lt;/p></description></item></channel></rss>