Description

A CSV File G-Query pulls column data within a specified CSV file into memory for the defined Domain Attributes within the query configuration and blends it with synthetically generated data. Two types of queries are available: CSV List and CSV Index


In This Article


When Should a CSV Query Be Used? 

  • Any time you want to query real data from a CSV file and blend it with synthetically generated data. 


Video Tutorial

The following video provides step-by-step instructions for a CSV file query: 



Two Types of CSV Queries

A CSV Query can be performed in one of two ways: 

  • CSV List - From a CSV file, pull rows of data with one or more columns into memory as a list of data.  
  • CSV Index - From a CSV file, pull rows of data with one or more columns into memory and retrieve any row via its row index.  

CSV File Query Configuration Components

A Test Data Query configuration has the following primary components: 

  • Parameters - Define the resource path, subdirectory, name, and variables for the Test Data Query.
  • CSV File Column Names - Select a CSV file to be imported for the Test Data Query. Displays the column names within the CSV file after importing.
  • Domain Attributes - Defines the Attributes that will be populated by the real data obtained from the CSV file.


Note: The setup process is the same for the CSV List and CSV Index query options. Only the parameters are different for these options.


Simple Use Case Example

A tester wants to query a CSV file for the Customer's first and last name. They want to blend the queried data with the following synthetically generated data: 

  • social security number (ssn)
  • date of birth (dob)
  • phone number


Additionally, they want the generated output format to be a flat JSON file that contains all 25 records that are in the original file.


Step 1 - Setup Project

For this example, the tester will need to complete the following: 

  1. Create a Customer Domain with the following Attributes.


  2. Set the Domain loopCount. It is set to '25' because that's how many records are in the file. 
  3. Assign the JSONFileReceiver to the Domain for flat JSON output.
  4. Create a Scenario for the Domain.


  5. Configure the Receiver Parameters. A subdirectory has been added in this example. 


  6. Configure the Property Keys for Attributes. The defaults have been used for this example, and everything is in quotes. 



Step 2 - Add a G-Query to the Project Version

  • Click on Add G-Query in the dashboard. 



  • Enter the Name and a Description
  • Select a Type (CSV List or CSV Index) and click Save.


Step 3 - Configure Query Parameters

Query Parameters define any resources and variables used during the query. Available parameters within the Parameters pane will vary based on the query type. 


For each query type, items with an asterisk (*) are required. 

  • Use the fields and drop-down menus to modify query parameters.
  • Click Save once finished.


CSV List Parameters

The following parameters are available for CSV List queries.


ParameterDescription
path*Defines the path where the CSV file is located.
subDirDefines an optional subdirectory under the resourcePath where the CSV file exists.
fileName*Defines the name of the CSV file located on the user's computer.
delimiter*Defines what delimiter is used to separate column data within the CSV file.
bufferSize*Defines how many rows to keep in memory at once from the CSV to avoid the memory out of exception. Defaults to 1000.
setLoop*setLoop allows you to OVERRIDE the loop count at the Scenario level and ONLY produce the number of rows defined in this list. Defaults to False.


CSV Index Parameters

The following parameters are available for CSV Index queries. 



ParameterDescription
path*Defines the path where the CSV file is located.
subDirDefines an optional subdirectory under the resourcePath where the CSV file exists.
fileName*Defines the name of the CSV file located on the user's computer.
delimiter*Defines what delimiter is used to separate column data within the CSV file.
rowIndex*References an Attribute whose value determines the row in the CSV file to index in real time. If the parameter is set to 4, the Generator will always return the 4th value of the CSV file.


Step 4 - Import the CSV File

  • Click on Import within the CSV File Column Names pane.



  • Click on Choose File to select a local file from your computer.
  • Browse to the file, select it, and click Open.


  • Click Save after selecting the file.


  • The file columns will appear within the CSV File Column Names pane, as shown below:


Step 5 - Add Domain Attributes and Columns

To finish the configuration, you must add the Domain Attributes that will be populated with data read from the CSV file columns for the Test Data Query. 


Note: This step must be completed for each queried column of data in the CSV file (first name and last name).

  • Click on Add below the Domain Attributes pane.


  • Select the Domain and Attribute.
  • Enter the name of the Column being read by the query in the CSV file.
  • Click Save to finish.


  • Repeat the above steps for each Domain Attribute/Column.



  • Click on Column Check to verify the configuration.



  • Click OK to close the message. If the check fails, check the query configuration.
     


Step 6 - (Optional) Add to a Test Data Case

Queries can be added to one or more individual test cases. When this is done, the query does not have to be downloaded, just the case and Scenario. For this example, a case will not be used. To learn more, click here


Step 7 - Generate Test Data 

It is time to generate the test data. The query will be performed during test data generation. The tester will perform the following for this example: 

  1. Download the Scenario. 
  2. Download the Test Data Query.
  3. Copy the Query Command in the Dashboard.
  4. Open a Command Prompt or Terminal window.
  5. Run the command at the command line. 



Note: Click here to see step-by-step instructions. Please note that downloading is not necessary when using G-Repository.


Original CSV File



Generated Output File

The first and last name has been included in the generated JSON file along with a synthetically generated social security number, date of birth, and phone number for each record.


  [
    {

      "id" : "1",
      "firstName" : "Breland",
      "lastName" : "Burwell",
      "dob" : "08-04-1961",
      "ssn" : "001-01-0001",
      "phoneNumber" : "(679) 590-8620"
    },
    {

      "id" : "2",
      "firstName" : "Pirtle",
      "lastName" : "Clair",
      "dob" : "08-04-1966",
      "ssn" : "001-01-0002",
      "phoneNumber" : "(707) 555-2820"
    },
    {

      "id" : "3",
      "firstName" : "Desousa",
      "lastName" : "Pittman",
      "dob" : "11-01-1971",
      "ssn" : "001-01-0003",
      "phoneNumber" : "(500) 625-1320"
    },
    {

      "id" : "4",
      "firstName" : "Burnell",
      "lastName" : "Burgett",
      "dob" : "02-13-1976",
      "ssn" : "001-01-0004",
      "phoneNumber" : "(320) 563-1820"
    },
    {

      "id" : "5",
      "firstName" : "Shearer",
      "lastName" : "Dugas",
      "dob" : "10-04-1981",
      "ssn" : "001-01-0005",
      "phoneNumber" : "(506) 737-2668"
    },
    {

      "id" : "6",
      "firstName" : "Cornett",
      "lastName" : "Ransom",
      "dob" : "12-05-1986",
      "ssn" : "001-01-0006",
      "phoneNumber" : "(570) 710-6565"
    },
    {

      "id" : "7",
      "firstName" : "Nolen",
      "lastName" : "Wendell",
      "dob" : "06-24-1991",
      "ssn" : "001-01-0007",
      "phoneNumber" : "(621) 637-8203"
    },
    {

      "id" : "8",
      "firstName" : "Markey",
      "lastName" : "Smythe",
      "dob" : "05-18-1996",
      "ssn" : "001-01-0008",
      "phoneNumber" : "(518) 726-9578"
    },
    {

      "id" : "9",
      "firstName" : "Kerley",
      "lastName" : "Krol",
      "dob" : "06-03-2001",
      "ssn" : "001-01-0009",
      "phoneNumber" : "(452) 653-1593"
    },
    {

      "id" : "10",
      "firstName" : "Alba",
      "lastName" : "Won",
      "dob" : "08-15-2006",
      "ssn" : "001-01-0010",
      "phoneNumber" : "(743) 740-9532"
    },
    {

      "id" : "11",
      "firstName" : "Link",
      "lastName" : "Baughman",
      "dob" : "02-21-2011",
      "ssn" : "001-01-0011",
      "phoneNumber" : "(614) 732-7647"
    },
    {

      "id" : "12",
      "firstName" : "Mcmanus",
      "lastName" : "Alfano",
      "dob" : "07-03-2016",
      "ssn" : "001-01-0012",
      "phoneNumber" : "(716) 175-4438"
    },
    {

      "id" : "13",
      "firstName" : "Elias",
      "lastName" : "Pete",
      "dob" : "10-05-2021",
      "ssn" : "001-01-0013",
      "phoneNumber" : "(500) 221-2628"
    },
    {

      "id" : "14",
      "firstName" : "Reiff",
      "lastName" : "Beeson",
      "dob" : "04-24-2026",
      "ssn" : "001-01-0014",
      "phoneNumber" : "(428) 161-5054"
    },
    {

      "id" : "15",
      "firstName" : "Hoskins",
      "lastName" : "Michaelis",
      "dob" : "04-19-2031",
      "ssn" : "001-01-0015",
      "phoneNumber" : "(513) 329-8911"
    },
    {

      "id" : "16",
      "firstName" : "Spencer",
      "lastName" : "Wimer",
      "dob" : "08-06-2036",
      "ssn" : "001-01-0016",
      "phoneNumber" : "(280) 772-4979"
    },
    {

      "id" : "17",
      "firstName" : "Flournoy",
      "lastName" : "Solberg",
      "dob" : "10-24-2041",
      "ssn" : "001-01-0017",
      "phoneNumber" : "(409) 536-6971"
    },
    {

      "id" : "18",
      "firstName" : "Rocha",
      "lastName" : "Bosch",
      "dob" : "07-10-2046",
      "ssn" : "001-01-0018",
      "phoneNumber" : "(793) 561-3158"
    },
    {

      "id" : "19",
      "firstName" : "Coen",
      "lastName" : "Appleton",
      "dob" : "06-27-2051",
      "ssn" : "001-01-0019",
      "phoneNumber" : "(613) 749-1985"
    },
    {

      "id" : "20",
      "firstName" : "Lundin",
      "lastName" : "Carlyle",
      "dob" : "12-12-2056",
      "ssn" : "001-01-0020",
      "phoneNumber" : "(453) 665-7043"
    },
    {

      "id" : "21",
      "firstName" : "Basham",
      "lastName" : "Hargrave",
      "dob" : "03-12-2061",
      "ssn" : "001-01-0021",
      "phoneNumber" : "(702) 440-8768"
    },
    {

      "id" : "22",
      "firstName" : "Earle",
      "lastName" : "Spalding",
      "dob" : "05-23-2066",
      "ssn" : "001-01-0022",
      "phoneNumber" : "(213) 440-7856"
    },
    {

      "id" : "23",
      "firstName" : "Carstens",
      "lastName" : "Muhammad",
      "dob" : "05-16-2071",
      "ssn" : "001-01-0023",
      "phoneNumber" : "(594) 525-9513"
    },
    {

      "id" : "24",
      "firstName" : "Zurita",
      "lastName" : "Rone",
      "dob" : "11-26-2076",
      "ssn" : "001-01-0024",
      "phoneNumber" : "(331) 482-1871"
    },
    {

      "id" : "25",
      "firstName" : "Fulkerson",
      "lastName" : "Marrero",
      "dob" : "02-12-2081",
      "ssn" : "001-01-0025",
      "phoneNumber" : "(605) 410-2360"
    }
  ]