Description

The CSVToMapGen Generator reads data from one or more columns within a specified CSV file and saves the data to memory. Once the data is in memory, the CSVFromMapGen can obtain the data for a particular column by Column Name for each Attribute. 


In This Article


When can the CSVToMapGen Generator be used? 

  • Any time column data needs to be read from a CSV file.
     

When should the CSVToMapGen Generator not be used?

  • Reading data from other file types (e.g., Excel, ORC)
  • Reading column data from a CSV file using a key or index reference. 


Does it work with any other Generators?

  • The CSVFromMapGen Generator reads the value of a specified column by Column Name from the data read and stored in memory by the CSVToMapGen Generator.


CSVToMapGen Parameters

The following parameters may be configured for the CSVToMapGen Generator. Items with an asterisk* are required. 

  • path* - Defines the path where the CSV file is located.
  • subDir - Defines an optional sub-directory under the resourcePath where the CSV file exists.
  • fileName* - Defines the name of the CSV file located on the user's system.
  • columnNames - Defines the list of columns to read the data from.
  • delimiter* - Defines what delimiter is used to separate column data within the CSV file.
  • bufferSize* - Defines how many rows to keep in memory from the CSV to avoid the memory out of exception.
  • setLoop* - Allows you to OVERRIDE the loop count at the Scenario level and ONLY produce the number of rows defined in this list. Note: This does not apply to GenRocket Express, as it does not use Scenarios.
  • list - Stores one value on each line in the list. To add values, type them in and then hit ENTER. Note that the listed value shown is only for simulation mode; when running a true Scenario, the data will be loaded from the specified resource.


CSVFromMapGen Parameters

The following parameters may be configured for the CSVFromMapGen Generator. Items with an asterisk* are required. 

  • columnName* - The name of the column in the CSV to read data from.
  • list - Stores one value on each line in the list. To add values, type them in and then hit ENTER. Note that the listed value shown is only for simulation mode; when running an actual Scenario, the data will be loaded from the specified resource.


Preview Showing Empty Values - List Parameter

The CSVToMapGen Generator reads the column data from the given CSV file and saves the values to memory. The CSVFromMapGen Generator then obtains that column data. Both actions are performed while running the Scenario on the user's system locally. 


The list parameter can be used to simulate data displayed in the Preview pane for one or both Generators on the GenRocket web app. 



If no values are entered for the list parameter, the preview will show Empty values for each record. 


When users add values to the list parameter, this data is simulated for preview only. The added values will appear in the Preview pane.



Use Case 1 - Read Column Data into Memory for a Single Attribute

A tester wants to read data from a column titled "Level" within a CSV file and use the read data for a programLevel Attribute within a User Domain. 


For this example, the CSVToMapGen and CSVFromMapGen Generators will be linked within the programLevel Attribute. 


CSV File

The CSVToMapGen Generator will read the values within the 'Level' column:


Project Setup

The User Domain has the following Attributes: 



AttributeDescriptionGenerator
firstNameGenerates the user's first name.NameGen
lastNameGenerates the user's last name. NameGen
programLevelReads data from the 'Level' column in CSV File and maps it to this Attribute.CSVToMapGen
CSVFromMapGen


Domain loopCount


Domain Receiver


Domain Scenario


programLevel Attribute

The CSVToMapGen and CSVFromMapGen Generators will be linked for the programLevel Attribute.



CSVToMapGen Generator (gen1)

  • fileName = CSVSample.csv
  • columnNames = Level
  • delimiter = pipe ( | )
  • buffersize = 6  Note: The buffer size matches the number of records in the CSV file.


CSVFromMapGen Generator (gen2)

  • columnName = Level


Sample Output

The programLevel column in the delimited file has been populated from the Level column within the CSV file.



Use Case 2 - Read Column Data into Memory for Multiple Attributes

A tester wants to read (query) data from multiple columns within a CSV file using the CSVToMapGen Generator. They then want to use the CSVFromMapGen Generator for specific Attributes to read the column data in memory by Column Name.


CSV File


Project Setup

A Customer Domain has been set up with the following Domains:


AttributeDescriptionGenerator(s)
csvDetailsReads CSV's 'Level' and 'Reward' columns into memory.

Note: This Attribute is not visible.
CSVToMapGen
firstNameGenerates the customer's first name.NameGen
lastNameGenerates the customer's last name.NameGen
programLevelReads 'Level' column data stored in memory by the csvDetails Attribute.CSVFromMapGen
rewardReads 'Reward' column data stored in memory by the csvDetails Attribute. CSVFromMapGen


Domain loopCount


Domain Receiver



Domain Scenario


csvDetails Attribute

The csvDetails Attribute uses the CSVToMapGen Generator to read the 'Level' and 'Reward' column data from the CSV file. This Attribute is not visible (i.e., hidden), so it is not part of the generated output.


CSVToMapGen Generator Configuration

  • fileName = CSVSample.csv
  • columnNames = Level, Reward
  • delimiter = comma ( , )
  • bufferSize = 6  Note: The value entered here matches the number of rows in the CSV file.


programLevel Attribute

The programLevel Attribute reads the data stored in memory from the 'Level' column in the CSV file. 

The CSVFromMapGen Generator has been assigned to it, and 'Level' has been added for the columnName parameter. 



reward Attribute

The reward Attribute reads the data stored in memory from the 'Reward' column in the CSV file. 

The CSVFromMapGen Generator has been assigned to it, and 'Reward' has been entered for the columnName parameter. 



Sample Output

The 'programLevel' and 'reward' columns in the delimited file have been populated from the 'Level' and 'Reward' columns within the CSV file.