wood burning stoves 2.0*
The moose likes Java in General and the fly likes Genric CSV generator with field names in Prop/Map Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Genric CSV generator with field names in Prop/Map" Watch "Genric CSV generator with field names in Prop/Map" New topic
Author

Genric CSV generator with field names in Prop/Map

Vijay Kumar koganti
Ranch Hand

Joined: Jan 23, 2006
Posts: 53
Hi all,

I am planning to write a generic CSV generator method that would take ObjectList and Map/properties file with all the pojo fields info. The method then has to
create a csv file by iterating through the list of objects and based on the Map/Properties file fetch all the field values(Fields are defined in the Properties file)
for each of object and create csv file at the end.
For Ex:
1. List of Employee Pojo Objects
2. Properties file with some of the fields from Employee pojo say EmpName,EmpID
3. Resultant CSV file :
vijay,12
kumar,34
ravi,45

What i am looking for is some pointers on what is the best way to do it and is there some thing that is readily available opensource that i can use/extend it.I wanted
to follow this approach so that if tomorrow some new fields has to be added i dont have to touch my code just update my properties file and it should work.

regards,
vijay


vijay kumar k.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
The http://faq.javaranch.com/java/AccessingFileFormats page lists several CSV-generating libraries. CSVBeans in particular sounds as if it does something like what you propose.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Genric CSV generator with field names in Prop/Map