Forum Discussion

easyfish's avatar
easyfish
Contributor
9 years ago

Need function in data source to write properties to a file

Hi,

 

Under Soapui datasink,  there are functions that we can write properties to a file or import properties from a file. Under data source, there is only function to import from a file. I would like to have the functiom that we can write data source properties to a file so that next time I can reuse it directly or reuse it little update.

 

Thanks for your kind support!

 

 

  • you can try to add a property transfer and dataSink steps. The idea is that you will transter data between you dataSource and DataSinc, and save them to a specific file.

     

    Alternatively, if you are comfortable with scripting, you can do a select from groovy (instead of using dataSource step), and save results to the file in the same script using a code example I gave you before.

  • NataliaB's avatar
    NataliaB
    Occasional Contributor

    if you want to write to excel, you can try this groovy script

     

    //open your file

    Workbook workbook = Workbook.getWorkbook(new File("PATH TO YOUR FILE"));

    //set it enable to edit
    WritableWorkbook copy = Workbook.createWorkbook(new File("PATH TO YOUR FILE"), workbook)
    WritableSheet sheet = copy.getSheet("STEET NAME IN THE FILE WHERE YOU WILL WRITE")

    //write to a cell

    sheet.addCell( new Label(COLUMN NUMBER,ROW NUMBER, YOUR TEXT))

    //close the file

    copy.write();
    copy.close();
    workbook.close();

  • Hello easyfish,

     

    Could you give us some more info on what you want to do, e.g. what kind of data source you have and what file format you need.

     

    Regards,

    Manne, Ready! API Developer

    • easyfish's avatar
      easyfish
      Contributor

      Thanks for your reply!

       

      I have a oracle jdbc data source.  Now we can import data source properties from a csv file.  The csv is like

      prop1A, prop1B,prop1D, prop1D

      prop2A, prop2B,prop2D, prop2D

       

      we can choose the row that we want to import. It is very convenient.

       

      What I want to have an inverted function.  We can export the current properties in datasource  to a csv file, which has the same format above.

       

      • NataliaB's avatar
        NataliaB
        Occasional Contributor

        you can try to add a property transfer and dataSink steps. The idea is that you will transter data between you dataSource and DataSinc, and save them to a specific file.

         

        Alternatively, if you are comfortable with scripting, you can do a select from groovy (instead of using dataSource step), and save results to the file in the same script using a code example I gave you before.