cancel
Showing results for 
Search instead for 
Did you mean: 

How to get specific row from DDT.CSVDriver

SOLVED
tuanvinh1008
Contributor

How to get specific row from DDT.CSVDriver

Hi all,

I have the csv data file like this have 10 rows

username,password
def,ids
abc,def
efc,pass
....
....

And I use DDT.CSVDriver to read that file and store it in a variable like this.

var testData = DDT.CSVDriver(path)

And now I have a case that wants to get a specific row in the testData variable. for example, I want to the row 2,6,7, or rows start from 4 to 8. How Testcomplete's methods support?

 

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Marsha_R
Community Hero

Re: How to get specific row from DDT.CSVDriver

DDT.CSVDriver is meant for looping through all  the rows in the csv file in sequential order.  If you want to pick out particular rows, then you'll have to check your row number in each iteration of the loop and then do something on the ones you want but skip the others.

https://support.smartbear.com/testcomplete/docs/reference/program-objects/ddt/csvdriver.html

 

If you're using a table variable, then you can reference each item in a row by row number and column name.  See the Using Table Variables section here>

https://support.smartbear.com/testcomplete/docs/testing-with/variables/data-types/table.html

View solution in original post

5 REPLIES 5
Marsha_R
Community Hero

Re: How to get specific row from DDT.CSVDriver

Would you use log message to print out the contents of your testData variable and let's see what's in there?

tuanvinh1008
Contributor

Re: How to get specific row from DDT.CSVDriver

@Marsha_R 

I mean I want to get the exact row number in the DataTable or dataset. for example, you have 10 rows in dataset or DDT.CSVDriver. and I want to get all data of the row #2, #5, #6. how to do that? 

Marsha_R
Community Hero

Re: How to get specific row from DDT.CSVDriver

DDT.CSVDriver is meant for looping through all  the rows in the csv file in sequential order.  If you want to pick out particular rows, then you'll have to check your row number in each iteration of the loop and then do something on the ones you want but skip the others.

https://support.smartbear.com/testcomplete/docs/reference/program-objects/ddt/csvdriver.html

 

If you're using a table variable, then you can reference each item in a row by row number and column name.  See the Using Table Variables section here>

https://support.smartbear.com/testcomplete/docs/testing-with/variables/data-types/table.html

View solution in original post

tuanvinh1008
Contributor

Re: How to get specific row from DDT.CSVDriver

@Marsha_R 

Could you give me the sample code how to item in a row by row number and column name if I using table variable. in the link's document. it just set value to table. how to retrieve it in a row by row?

Marsha_R
Community Hero

Re: How to get specific row from DDT.CSVDriver

In the document it shows you examples under Using Table Variables

 

Marsha_R_0-1621183286623.png

 

New Here?
Join us and watch the welcome video:
Announcements