cancel
Showing results for 
Search instead for 
Did you mean: 

How to get some records with specific condition in csv file

tuanvinh1008
Contributor

How to get some records with specific condition in csv file

Hi all,

I have a csv file like this template

TestcaseID,AccountKey,RealAccountNumber,AccountNumber
0001,1,4,10001
0001,2,3,10253
0001,4,2,20398
0002,5,3,19283
0002,6,2,10192
0003,7,1,01000

So I want to get records with conditions base on TestcaseID. So DDT.CSVDriver is supported or needs to other functions?

5 REPLIES 5
vinniew
Staff

Re: How to get some records with specific condition in csv file

Hi @tuanvinh1008 

 

I am not sure if using DDT is best if you want to call conditional values. 

 

Have you looked at using a table variable work here? 

 

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

 

I think this would be easier when creating your conditions as you can call values from that table variable. 

 

let me know how this goes 

 

KR 

 

Vincent

tuanvinh1008
Contributor

Re: How to get some records with specific condition in csv file

Hi @vinniew , It means i will read all data and convert it to table for retrieve data? Do you have any else solution if I don't use DDT.CSVDriver?

vinniew
Staff

Re: How to get some records with specific condition in csv file

Hi @tuanvinh1008 

 

Yes TC will store the table variable in TC. 

 

My response was based on the information shared, there could be other work arounds, TC is quite flexible after all.

 

Can you provide more context and details on what you are doing. 

 

This will help me and other members to fully understand what could looked at in terms other options

 

KR

 

Vinnie

tuanvinh1008
Contributor

Re: How to get some records with specific condition in csv file

My context is, I have the test data file (csv) like above and I want to read it from my script with conditions as I mentioned. I want to know Test Complete has any build-in command to read the file with that conditions or we need our own code to handle it.

 

Thanks

Marsha_R
Community Hero

Re: How to get some records with specific condition in csv file

I would just use the ddt driver to run through the file and put your condition in that loop.  

 

if (record has the right testid) then

    do something

 

 

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