org.apache.jmeter.report.processor

## Class CsvFileSampleSource

- java.lang.Object
- - org.apache.jmeter.report.processor.AbstractSampleSource
  - - org.apache.jmeter.report.processor.CsvFileSampleSource

All Implemented Interfaces:
  Runnable, SampleSource

    public class CsvFileSampleSource
    extends AbstractSampleSource

Read a csv source file and write its rows (samples) all the registered `SampleConsumer`s.
If there is several other source files with the same root name then those files are produced on their corresponding channels.

The root name of the files is determined by the source file name and is made of its name without the file extension :
Example: If `results.csv` is the source file name then `results` is the root file name.
The `CsvFileSampleSource` looks for all the files in the same directory of the main source file that have the same root file name
Example : if the directory contains `results.csv`, `results-1.csv`, `results-2.csv`, etc. then all these files will be read and produced on their corresponding channels.
The channel on which an input file will be produce is determined by its suffix

- If the input file is named `results-1.csv` then it will be produced on the channel 1.
- If the input file is named `results-2.csv` then it will be produced on the channel 2.
- If the input file is named `results.csv` then it will be produced on the channel 0.

Since:
  3.0

### Field Summary

Fields
`static String` `SOURCE_FILE_ATTRIBUTE` File name whose sample are being produced on the channel

### Constructor Summary

Constructors
Constructor and Description
`CsvFileSampleSource(File inputFile, char separator)` Build a sample source from the specified input file and character separator.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addSampleConsumer(SampleConsumer consumer)` Add a sample consumer to this sample source.
`void` `removeSampleConsumer(SampleConsumer consumer)` Remove a sample consumer from this sample source.
`void` `run()` Run this sample source. This sample source will start reading all inputs CSV files and produce their samples to this sample source registered sample consumers.
`void` `setSampleConsumers(List<SampleConsumer> consumers)` Sets the specified sample consumers that will consume samples produced by this sample source.

### Methods inherited from class org.apache.jmeter.report.processor.AbstractSampleSource

`getSampleContext, setSampleContext`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### SOURCE_FILE_ATTRIBUTE

    public static final String SOURCE_FILE_ATTRIBUTE

File name whose sample are being produced on the channel

See Also:
  Constant Field Values

### Constructor Detail

#### CsvFileSampleSource

    public CsvFileSampleSource(File inputFile,
                               char separator)

Build a sample source from the specified input file and character separator.

Parameters:
  `inputFile` - The input sample file (CSV file) (must not be `null`)
  `separator` - The character separator to be used for delimiting samples columns

### Method Detail

#### setSampleConsumers

    public void setSampleConsumers(List<SampleConsumer> consumers)

Description copied from interface: `SampleSource`
Sets the specified sample consumers that will consume samples produced by this sample source.

Specified by:
  `setSampleConsumers` in interface `SampleSource`
Specified by:
  `setSampleConsumers` in class `AbstractSampleSource`
Parameters:
  `consumers` - consumers to be set

#### addSampleConsumer

    public void addSampleConsumer(SampleConsumer consumer)

Description copied from interface: `SampleSource`
Add a sample consumer to this sample source.

Specified by:
  `addSampleConsumer` in interface `SampleSource`
Specified by:
  `addSampleConsumer` in class `AbstractSampleSource`
Parameters:
  `consumer` - consumer to be added

#### removeSampleConsumer

    public void removeSampleConsumer(SampleConsumer consumer)

Description copied from interface: `SampleSource`
Remove a sample consumer from this sample source.

Specified by:
  `removeSampleConsumer` in interface `SampleSource`
Specified by:
  `removeSampleConsumer` in class `AbstractSampleSource`
Parameters:
  `consumer` - consumer to be removed

#### run

    public void run()

Run this sample source.
This sample source will start reading all inputs CSV files and produce their samples to this sample source registered sample consumers.

Specified by:
  `run` in interface `Runnable`
Specified by:
  `run` in class `AbstractSampleSource`