Results 1 to 8 of 8
  1. #1
    padmajap13 is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default How to parse the CSV(Comma separation values)file and validate the file using java

    Hi all.
    This is urgent issue. pls help me. How to parse the CSV file and validate the file using Java

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  3. #3
    padmajap13 is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default HI

    No,Using Java.io package and validations also need

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  5. #5
    danielstoner's Avatar
    danielstoner is offline Senior Member
    Join Date
    Apr 2008
    Location
    Canada
    Posts
    191
    Rep Power
    7

    Default

    Read the file line by line (readLine()) and parse each line with StringTokenizer for commas(,) :)
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Yep, that's what I try to explain him. But no feedback there. He just looking a code. I don't like to just give a code. Why they don't try something. :) ;(

  7. #7
    padmajap13 is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default HIIIIII Eranga

    Thanks for ur support.pls send the code if u have any possible,pls share the code.I was tried whole day.but i didn`t get any proper output.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    OK try this, a part of it. Read a file and get each line of it. I give a part of it, because best thing is try something yourself and ask here if you stuck. Anyway,

    Java Code:
                FileReader myFile = new FileReader(path_to_CSV_file);
                BufferedReader InputFile = new BufferedReader(myFile);
                // Read the first line
                String currentRecord = InputFile.readLine();
                while(currentRecord != null)
                {
                    // Do the record validation here
                    
                    
                    // Important: get the next record.
                    currentRecord = InputFile.readLine();
                }
    In this way you can read each line of the file. Then think that how to separate data depend on the comma( , ) there are lots of way to do it. :)

Similar Threads

  1. Replies: 0
    Last Post: 04-16-2008, 11:58 PM
  2. Reading Float values from a file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 10:20 AM
  3. reading values from config file
    By sathish_2111 in forum Enterprise JavaBeans (EJB)
    Replies: 3
    Last Post: 08-10-2007, 04:09 PM
  4. Replies: 3
    Last Post: 08-01-2007, 06:15 PM
  5. how to parse an xml file
    By oregon in forum XML
    Replies: 3
    Last Post: 08-01-2007, 05:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •