cancel
Showing results for 
Search instead for 
Did you mean: 

Read csv using Javascript

SOLVED
Contributor

Read csv using Javascript

Hi everyone,

 

can any one guide me how to read a csv file using ado connection using javascrip.

 

Regards,

Krishna Kumar

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Read csv using Javascript

I wouldn't ready the file via an SQL query.  I've done this in the past.  Use aqFile.OpenTextFile (https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfile/opentextfile.html) to open the file for reading.  Then simply use the ReadLine method to read each line of the file in as you loop through the record set from your DB query.  You can then use, for the line itself, the aqString.GetListItem(https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/getlistitem.html) and other supporting methods to get the particular fields out of the line of the CSV file.

Alternatively... you could still use DDT.CSVDriver to open the CSV file and then, within a loop based upon the resulting DDT object, compare fields and rows as you loop through.  


Robert Martin
[Community Expert Group]
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

View solution in original post

4 REPLIES 4
Highlighted
Community Hero

Re: Read csv using Javascript

Why do you need to use an ADO connection?  What are you intending to do?  If you're looking at doing a data driven script, simply use the DDT.CSVDriver object.



Robert Martin
[Community Expert Group]
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
Highlighted
Contributor

Re: Read csv using Javascript

Requirement is to compare the CSV file with the DB values.

So though of using same query to retrieve the data.

 

Regards,

Krishna

Highlighted
Community Hero

Re: Read csv using Javascript

I wouldn't ready the file via an SQL query.  I've done this in the past.  Use aqFile.OpenTextFile (https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfile/opentextfile.html) to open the file for reading.  Then simply use the ReadLine method to read each line of the file in as you loop through the record set from your DB query.  You can then use, for the line itself, the aqString.GetListItem(https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/getlistitem.html) and other supporting methods to get the particular fields out of the line of the CSV file.

Alternatively... you could still use DDT.CSVDriver to open the CSV file and then, within a loop based upon the resulting DDT object, compare fields and rows as you loop through.  


Robert Martin
[Community Expert Group]
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

View solution in original post

Highlighted
Contributor

Re: Read csv using Javascript

@tristaanogre,

 

Thank you very much for your suggestion,

 

Regards,

Krishna