skip to content

CSV Data Sets

Feeding each iteration a fresh row from a file: header handling, delimiters, what happens at end of file, and the sharing mode that decides whether two threads ever see the same line.

on this pageshow

explore

questions

5

In JMeter's CSV Data Set Config, what happens if you leave Variable Names empty?

level: juniorimportance: must knowfreq 74%

answer

  1. Who names the columns here?
  2. One blank field changes everything
  3. Line one has two possible fates
  4. The ignore checkbox has a precondition

basics

~20 s

JMeter reads the file's first line and uses its fields as the variable names. That line is consumed as a header, never handed to a thread as data, and the Delimiter field must match the header's separator.

solid answer

~40 s

Leaving **Variable Names** empty tells JMeter's `CSV Data Set Config` to treat the file's first line as a header: it splits that line with the configured `Delimiter` and uses the resulting fields as JMeter variable names. The header is read once when the file is reserved, so no thread ever receives it as data. `Ignore first line` is consulted **only** when Variable Names is not empty — with an empty Variable Names field the first line must be the header, and ticking Ignore first line changes nothing. If the Delimiter does not match the header's separator, the entire line becomes one variable name and every `${USER}` reference is sent to the server literally instead of being replaced. Names are trimmed, so `USER, PASS` works.

code

csv · 4 lines
csv
USER,PASS
user00001,pw-8f3a
user00002,pw-11cd
user00003,pw-4b7e

go deeper

for a junior

Recall the two ways columns get names: type them into Variable Names, or leave it empty and let the file's first line be the header. Know that the header line is not sent as data.

for a middle

Explain that the header is read once when the file is reserved, that it is split with the Delimiter, and that Ignore first line is only consulted when Variable Names is non-empty.

for a senior

Show how a naming mistake presents in a real run: no error, an unresolved ${USER} in the request, or a BOM-prefixed column name when File encoding is set explicitly. Say how you would confirm it in one iteration.

for a principal

Own the convention: whether plans in your repo carry headers or typed names, and why one consistent choice removes a whole class of silent, per-plan data mismatches from review.

## Two ways to name the columns JMeter's **CSV Data Set Config** must learn a name for every column before it can put a row into thread variables, and the `Variable Names (comma-delimited)` field is the switch between the two ways it can do that. - **Field filled in** — the names you type are the names, matched to columns in file order. JMeter splits that field on **commas** whatever the `Delimiter` field is set to (the field's own label says so), and trims whitespace around each name, so `USER, PASS` is fine. - **Field empty** — JMeter reads the file's first line when it reserves the file, splits it with the configured **Delimiter**, and uses those fields as the variable names. That line is consumed at reserve time, so no thread ever receives it as data. Either way the element writes one row into the thread's variables at the start of each iteration, so `${USER}` in a sampler resolves to whatever row that thread currently holds. ## What "Ignore first line" actually controls The checkbox's own label in JMeter 6.0.0 is the whole rule: **Ignore first line (only used if Variable Names is not empty)**. It exists for the case where you want to name the columns yourself but the file still carries a header row you must not send as data. | Variable Names | Ignore first line | What happens to line 1 | |---|---|---| | `USER,PASS` | unticked | treated as data — the first thread to iterate logs in as `USER` / `PASS` | | `USER,PASS` | ticked | skipped; the names are the ones you typed | | empty | unticked | read as the header; it supplies the names | | empty | ticked | read as the header anyway; the tick changes nothing | The bottom row is the one candidates get wrong. With Variable Names empty the first line **must** be the header, and ticking the box does not make JMeter skip a second line as well. ## Where a 10,000-row credential file goes wrong - **Delimiter mismatch.** Set `Delimiter` to `,` on a tab-separated file and the whole header becomes a single variable name. Nothing errors; `${USER}` is simply never defined, and the sampler sends the eight characters `${USER}` to the server as the username. - **A byte order mark.** JMeter strips a BOM only when `File encoding` is left empty. Name an encoding explicitly and the BOM stays, so the first header field becomes an invisible-prefixed name that no `${...}` reference will ever match. - **An empty file.** With Variable Names empty there is no header to read, and the element fails at startup with `Could not read file header line for file ...` rather than running with no data. - **Recycling.** When the header mechanism is in play, JMeter skips the first line again every time it reopens the file, so a recycled run does not suddenly hand a thread the header row. ## Checking it in under a minute 1. Open the file's first line and count the separators; set `Delimiter` to match (`\t` for a tab). 2. Decide who names the columns and use exactly one mechanism — typed names, or an empty field plus a header. 3. Tick `Ignore first line` only when you typed names **and** the file really carries a header. 4. Run a single thread for one iteration and look at what the sampler actually sent; an unresolved `${USER}` in the request is the fastest possible confirmation that the naming is wrong.

  • When does the Ignore first line checkbox actually take effect in a CSV Data Set Config?
    Only when Variable Names is non-empty. It exists so you can name the columns yourself on a file that still carries a header row. With Variable Names empty the first line is the header by definition, and ticking the box does not skip an additional line.
  • If Recycle on EOF is on, does the header line get handed out as data on the second pass?
    No. When the header mechanism is active, JMeter reopens the file and discards the first line again before reading, so every pass through the file starts at the first data row.
  • What does JMeter do if the file you point Filename at is empty?
    With Variable Names empty there is no header to read, so the element fails at startup with 'Could not read file header line for file ...' rather than running with no variables defined.

saying these in an interview costs you the question

  • Says Ignore first line skips the header when Variable Names is empty.
  • Assumes the header row is also handed to the first thread as data.
  • Thinks the Variable Names field is split by the Delimiter rather than by commas.
  • Believes an empty Variable Names field means the columns get no names at all.
  • Expects a Delimiter mismatch to raise an error instead of failing silently.
open as a page

How does JMeter's CSV Data Set Config behave when it reaches the end of the file?

level: middleimportance: must knowfreq 78%

basics

~20 s

Two checkboxes decide. Recycle on EOF, ticked by default, reopens the file at line one. With Recycle off and Stop thread on EOF off, every variable becomes <EOF>. With Recycle off and Stop thread on, the thread stops.

open as a page

A password in your JMeter CSV Data Set Config file contains the delimiter. What happens?

level: middleimportance: should knowfreq 52%

basics

~20 s

The row splits into an extra field unless Allow quoted data is ticked and the value is wrapped in double quotes. Without it, later variables take the wrong fragments, and a variable the row cannot fill keeps its previous value.

open as a page

A JMeter CSV Data Set Config feeds 200 threads the same few rows. What went wrong?

level: seniorimportance: should knowfreq 58%

basics

~20 s

Sharing mode is set to Current thread, which opens a separate reader per thread, each starting at line one. Only All threads, the default, gives one shared file pointer so no two threads take the same line.

open as a page

In JMeter, why can two CSV Data Set Config elements naming one file consume it twice?

level: seniorimportance: nice to knowfreq 26%

basics

~20 s

JMeter keys the open file by the Filename string plus the Sharing mode suffix, not by the resolved file on disk. So logins.csv and ./logins.csv are two keys, and each gets its own reader starting at line one.

open as a page