Edit CSV File Test Data

Problem:

Sometimes it is required to edit the test data present in the CSV file before using it in the JMeter script. Let’s see how to edit the test data without using the BeanShell code.

Example:

A CSV File contains below values:
‘A123’
‘B456’
‘C789’

A CSV Data Set Config Element is used to fetch these values into a variable named ‘paramVal’. Refer to the screenshot:

Edit CSV File Data in JMeter
Figure 01: CSV Data Set Config Element

As per requirement, the value needs to pass in the request without quote (‘) i.e. A123, B456 and C789.

Solution:

  1. Add a ‘Debug Sampler’
  2. Add a ‘Regular Expression Extractor’ post processor under ‘Debug Sampler’
  3. Write an appropriate Regular Expression token to fetch the required value in the proper format. Save this value in another variable named ‘extractVal’
  4. Use ‘extractVal’ wherever required
Edit CSV File Data in JMeter
Figure 02: Regular Expression Extractor to edit the CSV file value

The fetched value in extractVal is A123.