commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chetan Sahasrabudhe" <>
Subject RE: CSV parsing/writing?
Date Mon, 30 May 2005 04:01:57 GMT
Parallel to this thought I am thinking of providing simple selfPopulate solutions for populating
CSV data to
any Java Object. 

I have my code ready with the implementation, of course it can be tweaked to get better optimization
and modularity.

I am using java reflection to populate POJO with CSV data. The rules for population and validations
are driven through properties file.

Here is a snapshot of propeties that are used.

This section is used to provide column sequence in CSV and bean attributes. 
The attribute names need to same as that in bean (Case sensitive). 
selfPopulate method uses setXxx pattern to call setter methods for storing CSV column values.

#End of column sequence

These are possible validation types. More can be added. 
I guess this can be pulled out of bean to some common place.

#validation types
#End of Validation types

This section is used to map columns with validation type. Notice that column sequence needs
to be maintained so as to
map appropriate validation type. 
I guess use of xml in place of properties file will make is more readable and easy to maintain.

#validationSequence to validation type mapping
#End of columnSequence to validation type mapping


-----Original Message-----
From: Don Seiler []
Sent: Friday, May 27, 2005 9:20 PM
To: Jakarta Commons Users List
Subject: Re: CSV parsing/writing?

On 09:43 Fri 27 May     , Don Seiler wrote:
> Anyway it would be the mechanism to reading/writing CSVRecord objects
> from/to the actual file.  The CSVRecord object would do the actual
> parsing/serializing for each line, given the parameters in its parent
> CSVFile.
> Obviously this is a very simplistic view of things.  I've not a great
> deal of experience dealing with events and listeners outside of swing.
> With DOM are we still talking about using the SAX setup and having
> everything go through XML at one point or another?  I see an example of
> a SAX/CSV parser at oreilly's website that sort of makes sense to me,
> but I may have to give it about 10 more reads to fully sink in.

Alright here goes.  I can just write my CSVFile class, let whatever user
apps add themselves as listeners to it.  The user apps then call parse
on that, CSVFile would then open the file and call functions on the
listeners, passing them an array of Strings (or other possible
selection) representing the values in that line.  User app can then do
whatever it wants it that data.

This setup on its own has nothing to do with DOM or XML, which I don't
believe it should.  If the client app wants to turn it into DOM/XML/JAXP
whatever they can then do that in their lineParsed() function (or
whatever its called) that CSVFile would call with the registered

Let me know if you think I've totaly misunderstood how to do this

Don Seiler

Public Key:
Fingerprint: 0B56 50D5 E91E 4D4C 83B7  207C 76AC 5DA2 FC87 F041

This message contains the information that may be privileged and is  the property of the KPIT
Cummins Infosystems LTD.It is intended only for the person to whom it is addressed. If you
are not intended recipient, you are not authorized to read, print , retain copy, disseminate,
distribute, or use this message or any part thereof. If you receive this message in error,
please notify the sender immediately and delete all copies of this message. KPIT Cummins does
not accept any liability for virus infected mails.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message