count the no of rows in csv file thats a data source

Ask general questions here.
rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

count the no of rows in csv file thats a data source

Post by rsudhak » Mon Mar 11, 2019 2:34 pm

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5343
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: count the no of rows in csv file thats a data source

Post by odklizec » Mon Mar 11, 2019 2:46 pm

Hi,

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 Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Re: count the no of rows in csv file thats a data source

Post by rsudhak » Thu Mar 21, 2019 4:57 pm

what is @refFile here? is it the header name? in the data source?

rsudhak
Posts: 78
Joined: Fri Jan 04, 2019 1:38 pm

Re: count the no of rows in csv file thats a data source

Post by rsudhak » Thu Mar 21, 2019 5:00 pm

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?