Re: How to avoid stumbling over empty lines in csv data loader
Daniel Dekany <[email protected]> Sat, 25 Feb 2006 22:00:05 +0100
| Newsgroups | gmane.comp.text.fmpp |
|---|---|
| Message-ID | <[email protected]> |
Saturday, February 25, 2006, 7:49:36 PM, Ralf Hauser wrote:
> 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.>>
It's rather strange that you are saying... Why would a few more empty
line at the end of a template file cause error? If the template
executes without error without those empty lines, then it will do with
the empty lines as well. I guess the error is caused by something
else.
> 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 = pp.loadData("csv", dataFile,{'separator':','})>
> <#list n_xml as d>
> <#[email protected] message = "\"${d?string}\"" /
BTW, it looks better to write: message = '"${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
> x_has_next>,</#if></#list>) VALUES (<#list n_xml.headers as x>'${d[x]}'<#if
> x_has_next>,</#if></#list>);
> </#list>
And, if you have empty lines after this, then d[x] is suddenly
undefined???
--
Best regards,
Daniel Dekany
-------------------------------------------------------
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