ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Testing  >>  Automation Testing  >>  QTP
 
 


 

 
 WinRunner interview questions  WinRunner Interview Questions
 Load Runner interview questions  Load Runner Interview Questions
 QTP interview questions  QTP Interview Questions
 Test Director interview questions  Test Director Interview Questions
 Rational TestSuite interview questions  Rational TestSuite Interview Questions
 Silk Test interview questions  Silk Test Interview Questions
 Automation Testing AllOther interview questions  Automation Testing AllOther Interview Questions
Question
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.
 Question Submitted By :: Allurbabu
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
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 ?    1 Yes 0 No
Divakar O
 
  Re: 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
# 2
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
Vinay.k
 
 
 
  Re: 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
# 3
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
Vipin Eden Ispl
 
  Re: 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
# 4
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 ?    2 Yes 0 No
Rajaputra
 

 
 
 
Other QTP Interview Questions
 
  Question Asked @ Answers
 
HOW TO DO THE BATCH TESTING USING QTP? Ordain-Solutions2
How To write script in QTP For Field Validation Example: password Field is accepting A range 8-20 characters only.How to write script?  3
how to use import and export sheet methods in qtp  1
How can we encrypt the username using recording mode in login window? There is 2 encrypted types what are it TCS1
i m tryed to use qtp in a user registration form but at the "image enter"part it gives a error when i run the qtp bcz the image is changed every time so it gives a error when i use regukar expreesion fot this it still gives a error value bcoz it reads the image code bt nt reconige the image which i enter in the image verification text box.so hw can i automate qtp for this function.plz give me a answer  1
What are the abbreviations for tsr and mtr? Ordain-Solutions14
how do u copy object repository?  1
Where we save all scripts in the QTP Ordain-Solutions3
can anyone tell me how to search a word/line in a document and to paste it in another file? Thanks in advance.  4
What is Environment Variable and when we apply this in QTP?  3
is qtp 9.2 supported for firefox browser3.0?bcoz when i tried to create scripts with the application run on firefox browser 3.0 then qtp 9.2 didn't ct=reate the scripts?  2
What is our exact stage involvement with QTP?  1
I have 2 Environment variable which holds int. I called into my test and addedup. but output is concatenating the values instead of Sum. Ex. Envi("a")= 10, Envi("b") = 20, c= Envi("a")+ Envi("b"). msgbox c ( Ans.1020). How to overcome this pblm? I used the add fn also.. BirlaSoft3
What are the recording modes and executing modes avialble in QTP? Polaris3
Pls anyone, tell me the script in QTP to find the number of links, and images in a webpage. Verry very urgent. I shall really be very thankful  2
what to do if application have 3 "ok" button with same logical name and same properties, how qtp can identify them. Intel9
WHAT IS A TEST STRATEGY & WHAT IS THE DIFFERENCE BETWEEN TEST STRATEGY & TEST PLAN? CTS17
from where we will retrieve data for data driven tests in qtp?  3
How to Install QTP on Citrix Environment? Possible send me the installation steps.. That would be great help  1
Do we get any issues if we run the test script on differentbrowsers?what are the options we need to set in QTP? CTS3
 
For more QTP Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com