Re: [FMPP] How to avoid stumbling over empty lines in csv data loader
Brought to you by:
ddekany
|
From: Daniel D. <dd...@fr...> - 2006-02-25 21:00:19
|
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>
> <#--@pp.warning 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
|