Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Iterate the datasource values

vkumar Posts: 29
edited February 2017 in Virtualize

I have requirment to read a column - all the rows of an excel data source and send in my response. How to iterate over all the rows and fetch the value in the excel data source.
Pl. help


  • You can import the excel into a data repository or create a Table datasource, then parameterize the field in your response with the column name.

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited February 2017

    A couple resources:
    Parasoft Virtualize User's Guide > Working with Large, Hierarchical Data Sets > Importing Data Into a Repository

    Parasoft Virtualize User's Guide > Virtualize Fundamentals > Parameterizing Tools with Data Source Values, Variables, and Extracted Values > Parameterizing Arrays of Varying Size

  • OmarR
    OmarR Posts: 233 admin

    Hi vkumar,

    The following video contains step-by-step instructions on how to accomplish this.

    In addition to the UserGuide (located in your Virtualize installation directory), you can also visit our Parasoft Resource Center online for more few helpful tutorials.

  • vkumar
    vkumar Posts: 29

    Dear All - Thank you for your responses.
    My question is slightly different.
    I have to iterate over all the rows in the data source and consolidate the values and send back in response.

    Example : If I have 10 rows in the data sources, I have to consolidate(concatenate) the values of column B of rows 1 to 10 from the excel and send back in my response.

    I doesn't have a need to for data correlation or any complex matching criterias. All i need to do is read al lthe rows from the d data source, consolidate the values and send back in response

    For this i need to know how to iterate over the excel rows one by one.


  • Thomas Moore
    Thomas Moore Posts: 82 admin

    Hi Vinoth,

    If you wish to use all of the values at one time, You can use the Extension Tool to pull all of the values from one column using
    ArrayList<String> list = context.getValues("data","values");

    Where "data" is the name of my Data Source and "values" is the name of the column I wish to pull from.

    From there, you can run the list object through a loop while adding each value in it to a String that will be returned by the Extension tool. It would look something like this:

    import com.parasoft.api.*; public String getAllValues(Object input, ScriptingContext context) { ArrayList<String> list = context.getValues("data","values"); String values = ""; for(int i = 0; i < list.size() - 1; i++) { values = values.concat(list.get(i) + " "); } return values; }

    At which point you could chain a Text Databank to the Extension Tool, and extract everything from its output to be used in parameterization.

    Hope this helps!


  • vkumar
    vkumar Posts: 29

    Thank you Thomas. This will help