Read data from excel file or csv in Custom keyword

Hi Arnel

Well its a magic what i can say but now its working even :slight_smile: i have’t change anything.

Oh really? That’s great!

Cheers!

1 Like

Hi Mehran, can you please share further info how use this data code in Keyword?

//get the excel file
Object excelData = ExcelFactory.getExcelDataWithDefaultSheet(“yout Excel File”, “your_SheetName”, true)

Here true mean the first line consider as a header.

Hi,

Let’s try the Read/Write Excel Custom Keyword plugin in Katalon Store. I think it can help.

Hi Mehran_Shafqat

Can you help me to get the CSV method to read data.My code for reading and writing back to CSV file is not working.
Appreciate the help.

-vidya

Hi Vidya,

Can you please share the code or any error screenshot ? will surely try to help.

Or I will create a Custom keyword and share with you for more easy to use

Thanks Mehran…It wil be a great help
but still code is as below

//File initialiation to write valid and broken links
File file = new File(“E:\brokenUrls.csv” );
FileWriter outputfile = new FileWriter(file);
CSVWriter writer = new CSVWriter(outputfile);

// have some code here which chek every link from the system and next write broken link on CSV file

if(respCode >= 400){
System.out.println(url+" is a broken link");
// add data to csv
writer.writeNext(url);

}

Hi guys,

Me also trying this getting same error/exception “java.io.FileNotFoundException:” and also object is not accepting method getRowNumbers().

I’ve same issue …please help!!

I’ve stored a data from website in a variable which i want to write in a CSV(in my local) using Katalon Studio . Can somebody please provide me the code as this functionality is new for me.

Thanks in Advance !!

Hi @ms.mayuri111

Please refer to this plugin:
https://store.katalon.com/product/34/Excel-Keywords

And the repository where samples are available:

Thanks for the quick help …I’m able to write the data in excel .
but facing issue while writing the data in CSV …Can you please help me in getting the solution for this ?

In my keyword, I used opencsv. One thing I had to do was read in the complete CSV, do my CRUD, then write it all back out.

def csvc = new File(targetCSV).readLines()findAll({x -> !x.isEmpty()})
def foundKey = false
csvc.findAll{it.startsWith(key + ',')}.each {
	foundKey = true
	def strindex = csvc.indexOf(it)
	//change the testdata
	csvc[strindex] = key + "," + keyValue
}
if (!foundKey){
	//New key, add to file with correct execution profile
	csvc[csvc.size()] = key + "," + keyValue
}
def newFile = new File(targetCSV)
PrintWriter printWriter = new PrintWriter(newFile)
csvc.each
	    { printWriter.println(it) }
printWriter.close()
1 Like

Hi @Arnel how to unzip and read CSV file and get the data from the cell, Could you please help me regarding this.

Hi @Mehran_Shafqat,

Can you please help me to read and get the data from csv file.

Hi @bhargavia,

You can try this

Hope that helps. . . :slight_smile:

Create an Excel Test Data
Select File > New > Test Data from the main menu. The New Test Data dialog is displayed. Enter the name for your test data and select Data Type as Excel File. Click OK.

Browse to the Excel file that you want to import into Katalon Studio.

Data from the selected Excel file is populated into the preview section below.

Save the Test Data when you finish. The data set defined here can be utilized in other configurations. For example, you can use it to input data for keywords in Manual View or data for Test Execution when setting up test suites.

Hello guys,
can i have some help ?
I have import an excel with user emails and passwords.
When i run the test alone it stops on the email input and does not move on.
When i run the whole test suite, the same issue appears again.

Any ideas?