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);
}