File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a CSV file

 
sonu rai
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to create a csv file , I have to give heading and beside it there will be detail of that heading. such as Name is an heading and bellow it name of students will be. So, what can i do.

Thank's
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Writing CSV files is very easy. "CSV" means "comma separated values". A CSV file consist of records; each line is a record, and the fields in each record are separated by commas.

You just write a program that opens the file for writing, first write the header line, then loop through the records, for each record write a line with the data for that record (fields separated by spaces), then close the file.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CSV does not have a concept of headers. It has rows and columns of values. ANy program processing a CSV file is of course free to treat certain rows or cells in special ways (as if they were headers).

It gets a little more complicated that Jesper described, though. Sometimes the delimiter is not a comma but a semicolon, and if the delimiter occurs inside of a cell, then the cell contents need to be enclosed in double quotes. And if the contents contain double quotes or newline characters, then those need to be escaped.

Before you've coded up all these special cases, you might as well use a ready-made library for reading and writing CSVs. The AccessingFileFormats FAQ page lists several such libraries.
 
poorna prakash parvathala
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this

http://ostermiller.org/utils/CSV.html

it has the utility programs you can extract to suit your needs
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic