Re: How to convert CSV row to Java object?
On 27-08-2010 18:38, Leonardo Azpurua wrote:
Since all the buzz with XML started several years ago, I've been scratching
my head trying to understand what actual advantages it might bring when used
to process files whose data structures are known and agreed upon in advance.
So far, with the exception of being able to boast that your application is
buzzword-compliant, I have found none. On the other hand, I have found
several "cons": depending on a library that is probably less efficient than
a traditional line oriented simple parser, overloading your project with
dependencies plus you have to learn a new formalization for which not many
good input editors exist (so, you must write code to turn source input into
XML, which is alsao more complex than just concatenating and expanding
strings).
And in this particular case, what is the point in having to learn XML to
write a barely readable definition instead of using Java (or any language),
which you already know and that may achieve the same results with probably
the same writing (and probably less thinking) effort?
I mean, if you have a CSV file, you may just read the lines, split them,
convert the data items that need to be converted and store the individual
values in an object.
Isn't all that XMLing a sort of overkill?
If you:
- only use "rectangular" data
- don't believe in documentation
- don't believe in type safeness
then I can not see any reason why not just use CSV instead of XML.
But a lot of people have needs for data with more advanced
structures than rows x columns, like the ability to document
the format in schema/DTD and the ability to check both
format and data values against the definition (checking
data values requires schema).
Arne