[Csv] read CSV file

kotaiah katragadda kotaiahkv at gmail.com
Sat Jul 19 15:12:35 CEST 2008


// I AM NOT ABLE TO READ SECOND LINE. ALLWAYS OVERDING FIRST LINE ONLY.
PLEASE HELP ME IN THIS

public class Test {

    public static void main(String args[]){
        String fileName="C:\\Documents and
Settings\\ats67.ATS\\Desktop\\test.csv";
        System.out.println("fileName==============="+fileName);
        InputStream in;
        ArrayList arr = new ArrayList();
        ArrayList mainArr = new ArrayList();
        OutputStream outputStream;
        try{
            File file=new File(fileName);
            if(file.exists()){
                if(file.canRead()){
                   in=new FileInputStream(file);
                   CSVParser csvparser=new CSVParser(in);
                   csvparser.setCommentStart("#;!");
                   csvparser.setEscapes("nrtf","\n\r\t\f");
                   int t1= csvparser.getLastLineNumber();
                   System.out.println("csvparser.getLastLineNumber" +t1);

                   String[] t;
                   int i=0;
                   System.out.println("p line"+csvparser.getLine());

                       while((t = csvparser.getLine())!=null){
                          int kk= csvparser.getLastLineNumber();

System.out.println("csvparser.getLastLineNumber()="+kk);
                          int length=t.length;
                         System.out.println("length="+length);
                         for(i=0;i<length;i++){
                               arr.add((String)(t[i]));
                           System.out.println("..........."+arr.get(i));
                           mainArr.add(arr);
                         }


                       }
                     }
                  }

        }catch(Exception e){
            System.out.println(e.getMessage());
        }

    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/csv/attachments/20080719/9953f408/attachment.htm>


More information about the Csv mailing list