1 Reply Latest reply: Jan 17, 2013 3:15 AM by POPS. RSS

    How to update a specific cell value in a CSV file.

    878316
      Hi

      I would like to know whether it is possible in openscript to update a cell value of the CSV file.

      For example if the test script requires to update the cell of 6th row and 8th column, then how to achieve through openscript API?

      Please kindly let me know.
        • 1. Re: How to update a specific cell value in a CSV file.
          POPS.
          Hi,

          Hope this helps!


          Table table;

          String[] rowvalus;

          int targetRow=5,targetColumn=7;

          /*
          * Note: Rows and columns are 0-based index.
          */

          table =utilities.loadCSV("C:\OracleATS\OFT\DataBank\Test.csv");
               
          rowvalus=table.getRows().get(targetRow).getAll();

          info("Before change :"+rowvalus[targetColumn]);

          rowvalus[targetColumn]="NewValue";

          utilities.saveCSV(table, "C:\OracleATS\OFT\DataBank\Test.csv", true);

          table =utilities.loadCSV("C:\OracleATS\OFT\DataBank\Test.csv");

          rowvalus=table.getRows().get(targetRow).getAll();

          info("After change :"+rowvalus[targetColumn]);


          Note:- Please first take the backup of your CSV file before using this code snippet

          Thanks
          -POPS