How to avoid stumbling over empty lines in csv data loader

"Ralf Hauser" <[email protected]> Sat, 25 Feb 2006 19:49:36 +0100
Newsgroups gmane.comp.text.fmpp
Message-ID <[email protected]>
Hi,

My CSV file sometimes ends with a few empty extra lines.
This causes fmpp to print the following error:

<<Caused by: freemarker.core.InvalidReferenceException: Expression d[x] =
is undefined on line 29, column 70 in sql.fdd.>>

In the code sample below, I wanted to avoid the error by
- converting the csv-row into a string
- trim
- test for the length

But as you see by the error in the below comment, this did not work.

Any hints are highly appreciated!

   Ralf

<#assign n_xml =3D pp.loadData("csv", dataFile,{'separator':','})>
<#list n_xml as d>
<#[email protected] message =3D "\"${d?string}\"" /

Caused by: freemarker.template.TemplateException: Expected number, date, =
or string. d evaluated instead to fmpp.models.CsvSequence$RowHash on =
line 22, column 28 in sql.fdd.

-->
 INSERT INTO  ${tbl} (<#list n_xml.headers as x>${x}<#if=20
   x_has_next>,</#if></#list>)  VALUES (<#list n_xml.headers as =
x>'${d[x]}'<#if=20
   x_has_next>,</#if></#list>);
</#list>



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642