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.

Answers were Sorted based on User's Feedback



How do u retrieve data from a text file into different variables. i.e. in a text file named &quo..

Answer / 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

How do u retrieve data from a text file into different variables. i.e. in a text file named &quo..

Answer / divakar o

Mr,

You have done almost,

Using FSO Readline, retrieve the line in to variable say A

then apply Split function on variable A and use the Comma(,)
as delimeter to split and get this data into a variable of
type array

then get each of the array element into required variable

need more info...
next time

Is This Answer Correct ?    4 Yes 1 No

How do u retrieve data from a text file into different variables. i.e. in a text file named &quo..

Answer / vipin eden ispl

set fso=createobject("scripting.filesystemobject")
set f=opentextfile(path,1)
set a=new regexp
a.pattren="[a-z]+|(\d)+"
a.ignorecase=true
a.global=true
do while f.atendofstream <>true
r=f.readline
set b=a.execute(r)
for each val in b
msgbox val
next
loop
f.close
dz will get u much information later u can modify as per ur
requriment.

Is This Answer Correct ?    1 Yes 0 No

How do u retrieve data from a text file into different variables. i.e. in a text file named &quo..

Answer / vinay.k

ya by FSO u can retrieve a line... make use of regular
expression u will arrive at the solution.for ex using \d u can
retrieve digits and \w will give u word char..

Is This Answer Correct ?    0 Yes 0 No

How do u retrieve data from a text file into different variables. i.e. in a text file named &quo..

Answer / kartheek

'try this cpde
Set fso = createobject("scripting.filesystemobject")
Set f = fso.OpenTextFile("C:\Documents and
Settings\kartheek\Desktop\Dummy.txt",1)
var1=f.ReadLine
k=1
var2=split(var1,",")
datatable.AddSheet("dummy")
datatable.GetSheet("dummy").AddParameter "country",""
datatable.GetSheet("dummy").AddParameter "number1",""
For i = 0 to ubound(var2)
datatable.GetSheet("dummy").SetCurrentRow(k)
If isnumeric(var2(i)) Then
datatable.GetSheet("dummy").GetParameter("number1").Value=var2(i)
k=k+1
else

datatable.GetSheet("dummy").GetParameter("country").Value=var2(i)

End If
Next

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More QTP Interview Questions

Hi, i am rani ,i am putting 1+years of fake exp ,so pls anyone explain how i get project (in real time) ? how it is tested ex: in banking ,test the number of textboxes in one window

3 Answers  


Hi Friends, Iam Beginner in QTP and i want to Try the software QTP. I checked the mercury site for QTP Trial version and i found QTP 9.0. The thing is that it supports windows 2000,Xp but not windows 98.And Iam using Windows 98 onlu and it's not possible for me to upgrade to windows 2000. Pls. guide me how to get the trial version of QTP which supports windows 98 Operating System The version may be 6.5 is ok for me.Thanks in Advance

2 Answers  


Hi, Plz give best Definition of Software Testing? Why we need Software Testing? and plz send 2+yrs experience Interview qutions (Manual,Qtp).

1 Answers  


How to export quicktest professional (qtp) results to an .xls file?

0 Answers  


A web page has two butons with same properties and rotating in clockwise direction. how to click on any of the button?

2 Answers   Virtusa,


what is object repository?

4 Answers  


hi gavasker i want how to merg OR's in QTP 8.2 by QTP Plus

1 Answers  


can any body tell me how i create a simple script and apply output value on it .pls send me a step by step process

0 Answers  


How can i open 5 multiple browser at once through QTP VB script and i want to login with 5 different credentials i already tried with this code but its entering credentials only for first browser and am using datatable to parameterize

2 Answers  


how to test background color and dynamic images during runtime

4 Answers   CTS,


How to record right click of a context menu and click on the selection ?

3 Answers  


Write a script to print below pattern 5 4 3 2 1 5 4 3 2 5 4 3 5 4 5

2 Answers  


Categories