Forum Discussion
9 Replies
- rraghvani
Champion Level 3
You can implement your own method to read and parse the CSV file. There's plenty of examples in various languages on the Internet. Also, generative AI chatbot can produce examples for you too.
- scot1967
Champion Level 3
👍🏼 I see.... That complicates things....
DDT.CSVDriver throws an exception when Microsoft Access Database Engine data access components are not installed. It's also listed as a pre-requisite for DDT on your (outdated) site here:
https://support.smartbear.com/testcomplete/docs/testing-with/data-driven/csv-storages.html
So, they are not going to move to the 64 bit supported version. That stinks. So yeah, creating a function / method to read it and call it from a script or a KWT would be the best way.
>> aqFile, aqTextFile, aqString <<https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfile/methods.html
https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqtextfile/methods.html
https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/methods.htmlOnce built a single function or method could read and parse the data for your existing looping structures. It could be called through out your projects. It would require a lot of re-factoring which stinks.
What is your environment now? Are your project(s) are script built or KWTs? It mostly matters for how comfortable you are with scripting. - Hassan_Ballan
Champion Level 3
You’ve run into a known limitation, at the moment there isn’t a true drop-in replacement provided. It would also be worth raising this as an enhancement request. Given that Access Runtime is now EoVS, having a native CSV driver without external dependencies would help a lot of teams in similar situations.
If you want to avoid a large refactor, a practical workaround is to create a small wrapper that mimics the DDT.CSVDriver interface. That way, your existing looping logic can remain mostly unchanged and you only replace the driver initialization.
This won’t be a perfect replacement, but it’s usually enough to keep existing tests running with minimal changes. Just be aware that a simple implementation may not handle more complex CSV cases (quoted values, embedded commas, etc.), so you may need to extend it depending on your data.
// In your script replace // var DataSS = DDT.CSVDriver(file); // with var DataSS = CustomCSVDriver(file);function CustomCSVDriver(file) { var f = aqFile.OpenTextFile(file, aqFile.faRead, aqFile.ctANSI); var lines = []; while (!f.IsEndOfFile()) { lines.push(f.ReadLine()); } f.Close(); var headers = lines[0].split(","); var index = 1; return { ColumnCount: headers.length, currentRow: [], ColumnName: function(i) { return headers[i]; }, Value: function(i) { return this.currentRow[i]; }, Next: function() { this.currentRow = lines[index].split(","); index++; }, EOF: function() { return index >= lines.length; }, Name: "CustomCSVDriver" }; }If this resolves your scenario, marking it as the solution helps future readers find it quickly.
- Rachel53461New Contributor
Thank you! We are able to get this idea working
- scot1967
Champion Level 3
Hi Rachel53461,
A CSV file is just a text file as you likely know. It can be read straight in as text and added to an object. aqFile, aqTextFile, aqString
You don't need the MS Access runtime.
Another option is the DDT.CSVDriver...
https://support.smartbear.com/testcomplete/docs/reference/program-objects/ddt/csvdriver.htmlMaybe I am not fully understanding your situation. If not hit me up with more information.
Always happy to help!... If you find my posts helpful drop me a Like👍 Be sure to mark the post as the Solution✅ when you get one to help others out and to credit the one who helped you. 😎
- Rachel53461New Contributor
DDT.CSVDriver throws an exception when Microsoft Access Database Engine data access components are not installed. It's also listed as a pre-requisite for DDT on your (outdated) site here:
https://support.smartbear.com/testcomplete/docs/testing-with/data-driven/csv-storages.html
I'm hoping there's an easy way to switch from DDT.CSVDriver to another method without having to rewrite all our test cases.
- scot1967
Champion Level 3
... Also, what is preventing you from installing the 64 bit version to keep your same code in place?
- Rachel53461New Contributor
The environment is Windows Server 64bit, and we're running the latest version of TestComplete x64 on it. Company policy prohibits installation of products that are EoVS, so we are not able to re-install Microsoft Access Database Engine 2016 now that it's gone EoVS. We also do not have Microsoft Office installed, nor does Access 365 Runtime appear to work.
This is the script that was reading from a CSV file. It crashes with an exception on line 13 where it tries to use DDT.CSVDriver since the Microsoft Data Access components are not installed.
/**@@Function * getCSVTable: Reads a CSV file and returns a 0 based 1 dimensional array * Param {String} file: * @returns a 0 based 1 dimensional array */ function getCSVTable(file) { var table = new Array(); var dataSource ="cloudapp" ; try { var DataSS =DDT.CSVDriver(file); for (colIndex = 0;colIndex <DataSS.ColumnCount;colIndex++) { colName[colIndex] = DataSS.ColumnName(colIndex); } //DataSS.Next(); var rowCount=0; //Define Header into multidimensional array while(!DataSS.EOF()) { table[rowCount] = new Object(); for (colCount=0;colCount<DataSS.ColumnCount;colCount++) { var tempStr = "table[" + rowCount + "]." + colName[colCount] + "=" + "'" + DataSS.Value(colCount) + "'"; if (eval(tempStr)=="$ID") { EntityID = Project.Variables.EntityID; tempStr = aqString.Replace(tempStr,"$ID",EntityID,true); } else if (eval(tempStr).indexOf(".sql")!=-1) { tempStr = getSqlResult(eval(tempStr),dataSource); } table[colCount] =eval(tempStr); } DataSS.Next(); rowCount++ } DDT.CloseDriver(DataSS.Name); } catch (exception) { Log.Error("getCSVData: " + exception.description); } return table; }- rraghvani
Champion Level 3
If you don’t have the necessary components for DDT.CSVDriver(), it will fail - this is expected.
You just need to replace DDT.CSVDriver() with your own CSV reading method that returns data in the same format, so the rest of your code continues to work as usual.