RE: How to avoid stumbling over empty lines in csv data loader
"Ralf Hauser" <[email protected]> Thu, 2 Mar 2006 08:58:32 +0100
| Newsgroups | gmane.comp.text.fmpp |
|---|---|
| Message-ID | <[email protected]> |
Daniel,
Thx for the hint.
> >> > The big problem with that is that empty lines are completely =
legal in
> >> > csv files. Not only they are legal, but they are in fact used by =
MS
> >> > Excel. They store rows where you have left all cells empty.
> > Just tested that with an interesting outcome. When inserting an
> > empty line, I still get the same error message referencing the
> > trailing empty lines, but the list already fails at the first empty
> line..
>=20
> Of course it fails on the first empty line. Your FTL scripts fails on
> the first empty cell that it reaches, as you have not written it to
> handle empty cells.
Ok, please see below an attempt to do this.
While as per http://freemarker.org/docs/ref_directive_list.html, there =
is a <#break>, there doesn't appear to be a <#continue>
But perhaps I don't need that. Do you think there is any improvement =
potential to the below?
Regards
Ralf
<#list n_xml as d>
<#if d?exists>
<#list n_xml.headers as x><#if
d[x]?exists><#assign continue=3D"true"><#else
><#assign continue=3D"false"></#if></#list>
<#if continue=3D"true">
INSERT INTO ${tbl} (<#list n_xml.headers as x>${x}<#if=20
x_has_next>,</#if></#list>) VALUES (<#list n_xml.headers as x>'<#if =
d[x]?exists>${d[x]}<#else
><@pp.warning message =3D "skipping empty cell ${x_index}" /> =
</#if>'<#if=20
x_has_next>,</#if></#list>);
<#else>
<@pp.warning message =3D "skipping empty line0 ${d_index}" />
</#if>
<#else><@pp.warning message =3D "skipping empty line1 ${d_index}" =
/></#if>
</#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