Hi all,
I need to find the no of rows in the data source that's provided in the code, what's the best way to do it?
Thanks,
Rajee
count the no of rows in csv file thats a data source
Re: count the no of rows in csv file thats a data source
Hi,
You can use something like this:
You can use something like this:
//create CSV data connector string refConnector = "CSVConnector"; //get data from ref. CSV Ranorex.Core.Data.CsvDataConnector refCSVConnector = new Ranorex.Core.Data.CsvDataConnector(refConnector,@refFile,true); refCSVConnector.SeparatorChar = ','; Ranorex.Core.Data.ColumnCollection refCSVColumns = new Ranorex.Core.Data.ColumnCollection(); Ranorex.Core.Data.RowCollection refCSVRows = new Ranorex.Core.Data.RowCollection(refCSVColumns); //load CSV connector refCSVConnector.LoadData(out refCSVColumns, out refCSVRows); //get number of rows int refCSVRowsCount = refCSVRows.Count;
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: count the no of rows in csv file thats a data source
what is @refFile here? is it the header name? in the data source?
Re: count the no of rows in csv file thats a data source
public CsvDataConnector(string name, string fileName, bool withHeaders)
{
this..ctor(name, fileName, withHeaders, CheckState.Indeterminate);
}
for tghe file name do I have to give the whole path?
{
this..ctor(name, fileName, withHeaders, CheckState.Indeterminate);
}
for tghe file name do I have to give the whole path?
Re: count the no of rows in csv file thats a data source
Works also good for Excel files
//create excel data connector string refConnector = "ExcelConnector"; //get data from ref. Excel file Ranorex.Core.Data.ExcelDataConnector excelConnector = new Ranorex.Core.Data.ExcelDataConnector(refConnector,@"C:\temp\excelfile.xlsx","(insert your sheet name here)","A:A",CheckState.Unchecked); Ranorex.Core.Data.ColumnCollection columnCollection = new Ranorex.Core.Data.ColumnCollection(); Ranorex.Core.Data.RowCollection rowCollection = new Ranorex.Core.Data.RowCollection(columnCollection); excelConnector.LoadData(out columnCollection, out rowCollection); int linecounter = rowCollection.Count; Report.Info("Excel-Tab has "+linecounter.ToString())+" rows";