Iterate the datasource values

vkumarvkumar 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_parasoftbenken_parasoft Posts: 1,018 ✭✭✭
    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

  • OmarROmarR Posts: 231 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.

  • vkumarvkumar 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 MooreThomas 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!


  • vkumarvkumar Posts: 29

    Thank you Thomas. This will help

Sign In or Register to comment.