Unanswered question

How to fetch values from a csv file based on line number and column name as input

I'm new to Neoload - my Scenario is
1) Get an API response and write a specific value into a text file append with "|" value. - Done
2) Read the file and extract value based on Line number and Column values in script - Not successful

  • I able to create a file variable and reading the number of lines from the text file.
  • 3) How to use "reader.readAsText(fileName);" in neoload script , What is the package I need to add in my code. I'm using neoload latest version 6.5.1

    Please help me how to achieve that.

    Code I'm trying

    var fileName = "C:\\TestResult\\LoadTest\\XXX.txt";

    //Read File and get line count
    var reader = new Packages.java.io.LineNumberReader(new Packages.java.io.FileReader(fileName));
    while ((reader.readLine()) != null) {
    var line = reader.getLineNumber();

    }
    var lineCount = reader.getLineNumber();
    reader.close();
    logger.debug("Line number is = "+lineCount);
    context.variableManager.setValue("LoopCount",lineCount);

    var check = context.variableManager.getValue("logFileRead");

    var i;
    for(i=0 ; i < lineCount;i++){
    logger.debug("Line number loop = "+lineCount);
    // Is that possible to extract the file varibale here with columnname_line number ????

    }

Lakshmi Narayanan P.
Lakshmi Narayanan P.

Lakshmi Narayanan P.

Level
0
3 / 100
points

No answers