dynamic traversal of csv records
"Ralf Hauser" <[email protected]> Thu, 24 Feb 2005 20:16:13 +0100
| Newsgroups | gmane.comp.text.fmpp |
|---|---|
| Message-ID | <[email protected]> |
How would I dynamically traverse through my csv data?
Basically I want not to access the columns of the table by name, but by
position. E.g. instead of
<#list flowers as flower>
<tr><td>${flower.name}...
as in http://fmpp.sourceforge.net/dataloader.html#key_csv, I would want to
just access
<#list flowers as flower>
<tr><td>${flower.1}...
and "1" being column 1
Also, I would need an inner loop if I not only don't want to use the column
name to access the field values, but also don't know ahead of time how many
columns there are.
I see in
http://freemarker.org/docs/ref_directive_list.html#ref.directive.list
that there is "item_index" and "item_has_next" to handle dynamic length
lists, i.e. the "vertical" of the table.
I guess, I could convert the "flower" data structure into a sequence again,
then, it would be possible to create an inner loop... and thus handle the
"horizontal" of the table...
Basically I want to create one cvs to sql-insert statement macro that I can
use for any csv. I think it is not too hard to get the headers right with
the
<#list flowers.headers as h>
approach, however, I would need a hint how to do the same on each row's
content?
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click