Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieving data from Txt file into datatable
#2
Not Solved
i am not able know the error you have committed so i have posting the code which i use
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)
Reply


Messages In This Thread
RE: Retrieving data from Txt file into datatable - by vinod123 - 07-17-2013, 09:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to append date to xls file using qtp datatable methods? yona34 1 1,481 05-04-2018, 08:56 PM
Last Post: Ankur
  dtLocalSheet empty even though excel file contains data cantorre 2 2,242 05-10-2017, 12:47 PM
Last Post: vidhi
  Grab multiple line data from log file haziqwebs 0 1,708 10-19-2016, 01:28 PM
Last Post: haziqwebs
  The DataTable.ExportSheet operation failed. Invalid file. Niraj 2 6,032 05-05-2015, 11:40 PM
Last Post: babu123
Smile Need to validate a .txt file and .jpeg image. aman8604 0 2,108 04-09-2015, 11:33 AM
Last Post: aman8604

Forum Jump:


Users browsing this thread: 1 Guest(s)