> -----Original Message-----
> From: James Strachan [mailto:[EMAIL PROTECTED]]
> Sent: Donnerstag, 30. Januar 2003 15:27
> To: Jakarta Commons Users List
> Subject: Re: [jelly] csv file to database
>
>
> From: "Gordon" <[EMAIL PROTECTED]>
> > 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
recordSeparator.
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.

Bernhard


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to