Quaatso Education

Home Forums Selenium Forum Not able to open the url while using chrome driver Reply To: Not able to open the url while using chrome driver

Reply To: Not able to open the url while using chrome driver

Home Forums Selenium Forum Not able to open the url while using chrome driver Reply To: Not able to open the url while using chrome driver

#4082

Shobhna Garg
Participant

package testData;

 

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

import java.util.ArrayList;

 

 

public class CsvTestData {

 

 

public static void main(String[] args) throws IOException {

getCsvData();

}

 

//@Paramters

public static Object[][] getCsvData() throws IOException

 

{

ArrayList<String> dataList = new ArrayList<String>();

 

File f = new File(“C:\\Users\\shobhna\\Desktop\\testdata.csv”);

FileReader fr = new FileReader(f);

BufferedReader reader = new BufferedReader(fr);

String line = null;

int row = 0;

int Columns = 0;

while ((line = reader.readLine())!= null)

{

if (row == 0)

continue;

if(line.charAt(0) == ‘#’)

continue;

 

String [] lineArray = line.split(“,”);

Columns = lineArray.length;

for (int i = 0; i < lineArray.length; i++)

{

String data = lineArray[i];

dataList.add(data);

 

} row ++;

 

}

reader.close();

 

// converting from 1d to 2d

Object [][] csvDataArray = new Object [row][Columns];

int index = 0;

for (int i=0 ; i < csvDataArray.length ; i++)

{

for (int j=0; j < csvDataArray[i].length; j++)

{

csvDataArray[i][j]= dataList.get(index);

index ++;

}

}

// just for testing this code

for (int i = 0; i < csvDataArray.length; i++) {

for (int j = 0; j < csvDataArray[i].length; j++) {

System.out.print(csvDataArray[i][j] + “\t”);

}

System.out.println();

}

 

 

return csvDataArray;

}

 

}