commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernhard Wagner">
Subject RE: [jelly] csv file to database
Date Thu, 30 Jan 2003 15:12:19 GMT

> -----Original Message-----
> From: James Strachan []
> Sent: Donnerstag, 30. Januar 2003 15:27
> To: Jakarta Commons Users List
> Subject: Re: [jelly] csv file to database
> From: "Gordon" <>
> > Would Jelly be a good tool to import a CSV file into a database? If so
> > what tag would I use to parse the CSV file?
> It might be nice to write a new tag or bean to parse a CSV and
> iterate over
> its rows providing a List for each row. Then you could do things like
> e.g.
> <csv:forEach var="row" uri="foo.csv" colSeperator=",">
>     <sql:update>
>         insert into foo (a, b, c) values (?, ?, ?)
>         <sql:param value="${row[0]}"/>
>         <sql:param value="${row[1]}"/>
>         <sql:param value="${row[2]}"/>
>     </sql:update>
> </csv:forEach>
> James

Additionally, I would add an attribute to the csv tag called
There are some conventions as to how csv fields are encoded (particularly in
M$ environments), e.g. how to escape commas within fields when comma is the
field separator (typically by quoting the field with double quotes (");
double quotes themselves within quoted fields are quoted as double double
quotes (""), etc. etc.).
One trap that should be avoided: newlines within fields should not be
misinterpreted as record separators...
I am currently unaware of a Java library that would support these
requirements but am willing to contribute outlining/implementing something
like this.


View raw message