Getting error message when trying to read CSV and XLSX file
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Getting error message when trying to read CSV and XLSX file
I am using following script code for reading CSV and XLSX file.
Issue with Excel File :
JavaScript runtime error.
External table is not in the expected format
function GetCol1Unique()
{
var MyExcelRecords;
var fileName = "C:\\Users\\"+Sys.UserName+"\\Downloads\\data.xlsx";
MyExcelRecords = DDT.ExcelDriver(fileName,"Export",true)
MyExcelRecords.ADOCommandObject.CommandText = "SELECT DISTINCT [Policy ID] from [Export$]";
var rowCount=0;
while (!MyExcelRecords.EOF())
{
rowCount++;
MyExcelRecords.Next();
}
Log.Message(rowCount);
DDT.CloseDriver(MyExcelRecords.Name);
}
Issue with CSV File
In CSV file reading we are getting error :Database object is read only”.
var latestFile.Path = "C:\\Users\\"+Sys.UserName+"\\Downloads\\data.csv";
if (aqFile.Exists(latestFile.Path))
{
var csvFile =DDT.CSVDriver(latestFile.Path)
var count =0;
while (!csvFile.EOF())
{
count++;
csvFile.Next();
}
Log.Message(count);
DDT.CloseDriver(csvFile.Name);
}
- Labels:
-
Script Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Excel example,
CSV example,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The CSV file is not in a format that DDT.CSVDriver likes. If I change the file format, then it works,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is any way to save file in correct format using script.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I saved the file using Excel. You will have to write a script to remove quotes and replace tabs with a comma.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you help me out to give some outline to write script ?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have tried but no luck to save file in correct format for further access.
