QTP Forum
Shopmotion


Retrieving data from Txt file into datatable Empty
Search
 
 

Display results as :
 


Rechercher Advanced Search

Poll
Keywords

Latest topics
September 2019
MonTueWedThuFriSatSun
      1
2345678
9101112131415
16171819202122
23242526272829
30      

Calendar Calendar

Affiliates
free forum


Retrieving data from Txt file into datatable

Go down

Retrieving data from Txt file into datatable Empty Retrieving data from Txt file into datatable

Post by thomasdfg on Wed Jun 18, 2014 5:32 pm

Code:
Public Function ReadLineTextFile (strTextFile)
Dim fso, MyFile
Dim arrPairs, arrColumns, i
Set fso = CreateObject("Scripting.FileSystemObject")
  ' Open the file for reading only
  Set MyFile = fso.OpenTextFile(strTextFile, 1)
  ' Read the input file
  ReadLineTextFile = MyFile.ReadLine
  ' Load the Global DataSheet.
  arrPairs = Split(ReadLineTextFile, "|")
  ' Note: This loop begins at Index 3 because Indices 0, 1, and 2
  '      (CurrentURL, CurrentBrowser, and CurrentPage) are already
  '      in the Global DataSheet)
  For i = 3 To UBound(arrPairs) - 1
    arrColumns = Split(arrPairs(i), ";")
    DataTable.GlobalSheet.AddParameter arrColumns(0), ""
    DataTable.Value(arrColumns(0), dtGlobalSheet) = arrColumns(1)
  Next
End Function '  ReadLineTextFile (strTextFile)
In your test script, just identify the path and filename of the text file...
  ' Identify the name of the input file to use.
  strTextFilePath = "C:\Test Data Files\"
  strTextFile = strTextFilePath & "FileName.txt"
Then just call the function when you need to...
  Call ReadLineTextFile (strTextFile)
thomasdfg
thomasdfg

Posts : 11
Join date : 2014-06-18
Age : 34
Location : Hyderabad

View user profile

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum