Is there any way to retrieve csv row numbers
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there any way to retrieve csv row numbers
I have suppose 15 records in csv. and with each record I want to update some value say if there is first row then the value should be "Val_1". For second record, it should be "Val_2" and so on.
So, for example, in "Val_4" value, the part "Val_" is to be remained contant only the number part will be updated by the CSV record row number.
Is this possible?
Thanks,
Vikas.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The CSV records don't have native Row numbers. What I would do is, since I'm assuming you're using something like DDT.CSVDriver to drive reading your file, is to just put a counter in your while loop to increment each time through, tracking the numbers. Then utilize that counter to append your values.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi vikassardesai,
Please try using the below snippet
Dim objFSO, dataArray, clippedArray
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Create an array out of the CSV
'open the data file
Set oTextStream = objFSO.OpenTextFile("C:\Users\ds\Desktop\Quota\new_file.csv")
Set newFile = objFSO.CreateTextFile("C:\Users\ds\Desktop\loginfo.txt")
'make an array from the data file
dataArray = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
Log.Message ("No. Of rows is " & UBound(dataArray))
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, @Krishna_Kumar , I wouldn't go that way. For two reasons.
1) The DDT method I suggested is more compact and better suited for iterating CSV files, along with it being self-contained within the TC environment
2) TestComplete has it's own wrappers around the FileSystemObject so creating an extraneous instance of it is redundant (e.g., aqFile, aqFileSystem, aqTestFile, etc).
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
