How do u retrieve data from a text file into different
variables. i.e.
in a text file named "source" , the data is like :
india,1000,japan,200,china,50,singapore,45050
this is given in the first line of the text file.
in the second line of the text file the dta is:
sun,moon,planet,river,earth,water

if u use "readline" method by using FSO concept u can
retrieve the entire line in to a variable. but i want to
import each field (ex: "india" in one variable, "1000" in
another variable etc..). Apprecitae proper replies.

Answer Posted / rajaputra

Hi i got the solution for you.Here it is...
Just go through it, and copy and paste in QTP and run.
You will get it.

'''''''''''Importing Data From Flat File using split''''''
''Source.txt file is having following data
''Arunsingh,40000,KiranKumar,35000,Chandra,50000,Rajesh,20000
''Test Engineer,Developer,Project Leader,HR Executive

Set fso=createobject("scripting.filesystemobject")
Set z=fso.opentextfile("c:\source.txt",1)
l=1
While not z.atendofline
i=1
k=1
count=1
parname=inputbox("Enter Name of The Parameter "&l)
'''''Enter the requiered parameter names
datatable.GetSheet(1).addparameter parname,""
n=z.readline
a=split(n,",")
For j=lbound(a) to ubound(a)

If isnumeric(a(j)) Then
If count=1 Then
datatable.GetSheet(1).addparameter
"Salary",""
count=count+1
end if
datatable.SetCurrentRow(k)
m=l +1
datatable(m,1)=a(j)
k=k+1
else
datatable.SetCurrentRow(i)
datatable(l,1)=a(j)
i=i+1
end if
Next
l=m
l=l+1
Wend


If you have any doubts please contact me at
r.arunsingh@gmail.com

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which recording modes need more memory?

571


how to compare two bitmaps( 1. clients requirement & 2. Designed by dev) in qtp 8.2 wann clear steps

1665


WHAT IS THE DIFFERENCE BETWEEN QTP SCRIPT AND VB SCRIPT? HOW MUCH PERCENTAGE WE USE IN QTP SCRIPT REAL TIME AND HOW MUCH PERCEN OF VB SCRIPT,,,,,,,

1492


I had installed QTP 9.2. It is working fine but whenever I open QTP, it is trying to reinstall the below-mentioned files again and again "QTP92PS82UPGRADE.exe", "recogn.dll". If anybody has these files, please provide those files in this site or you can send that files to my mail id also (lravi4u@yahoo.com). If you don't know where the files will be in the QTP, search in the QTP software CD or path of QTP program installed (C:\Program Files\Mercury Interactive\QuickTest Professional)

1444


If an application name changes frequently i.e while recording it has the name, in this case, how do qtp handles?

576






What is standalone database?

1739


what is clean sweep?

1506


What is qtpro? What is quick test pro? What is a quick test professional?

578


How do we analyze the checkpoint results?

569


what is the frame work in J-meter?

1588


how will you load the test cases in ddt?

1590


How to upload excel files into Quality Center using QTP Script and how to delete excel files from Quality?

606


in qtp if we record a object and we record the object using virtual wizard then by which way the object is recognized that means recorded

1512


can anyone tell me what to say in interview when interviewer asks about "tell me about your framework in your project"?

1394


if mandatory and Assitive propertys are shows same how will u write skript in QTP window

1616