18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Read and write csv files in Twist with sahi driver

harikareddy762harikareddy762 Members
edited November -1 in Sahi - Open Source
Hi,

I am using Twist with sahi driver. And i would be using java version to write the code.

Can somebody help me the syntax in java version for _readCSVFile and _writeCSVFile? I tried using it as
Var data = readCSVFile("c:/test.csv"), but it throws an error that method is not defined.

Do let me know if i need to have any other jar files that are needed prior to reading csv files in Twist.

Thanks,
Harika

Comments

  • Hi harikareddy762,

    It is not possible to write into a CSV, but you can read from a CSV by using the following code:
    public void testReadCSV(){
            File file = new File("E:/simpleCSV.csv");
            String output = net.sf.sahi.util.Utils.readFileAsString(file);
            System.out.println(output);
        }
    

    Also, add import java.io.File; at the starting.

    Regards
    Sumitra
  • narayannarayan Administrators
    Hi Harika,

    _readCSVFile and _writeCSVFiles are not currently available in the Java version. But it is fairly trivial to use some java code to do the read and write. When using the Java version, Sahi APIs only give you access to the browser. The rest of the APIs like read, write from files etc. are be done using Java or some APIs in Twist. You could ask the Twist team for it.

    Regards,
    Narayan
  • Can anybody write a small program for readCSV file.
Sign In or Register to comment.