4 Replies Latest reply: Nov 26, 2007 8:00 AM by 807603 RSS

    How to store data in .csv file

    807603
      Hi...

      I need to export the data in csv format, after retrieving from Database... i am using POI for inserting data from MS Excel to Database... but unable to find any method in POI to store the data in .csv format... need u guys help...

      plz guide me... if there is any method in POI for this purpose or i need to use any other api... (its details)

      Thanks in advance
        • 1. Re: How to store data in .csv file
          807603
          for writing a .csv file you dont need any fancy API just use java.io
          • 2. Re: How to store data in .csv file
            807603
            Well, you may need to do a little work, if CSV fields may happen to contain inconvenient characters like quotes, commas, newlines etc.. Basically the rules are: If a field contains comma, quote or newline, or has leading or trailing whitespace then enclose it in double quotes. If it contains a double quote character then replace it with two double quotes.
            • 3. Re: How to store data in .csv file
              800308
              and if it contains two double qoutes?

              I think someone said that apache has an open source csv reader/writer library... which I presume would conform to the "best open standard" whatever that it is, and hence take care of all this crapolla for you.
              • 4. Re: How to store data in .csv file
                807603
                corlettk wrote:
                and if it contains two double qoutes?
                Double each of them, of course
                I think someone said that apache has an open source csv reader/writer library... which I presume would conform to the "best open standard" whatever that it is, and hence take care of all this crapolla for you.
                Very likely. Google will probably turn up a bunch.