This is an interesting problem.
Jason's solution is the way to do it inside of a workspace without dipping into
the world of TCL.
If there was a large amount of data, then I'd suggest exploring writing a Tcl
proc that did this and calling it with the Tclcaller. The proc would look
something like the Tcl that the ListDuplicateRemover uses, only it would be
simpler, in that it would loop over all the elements of the list, and for each
one, it would just do a:
set attrName $FME_Attributes(...name of list attribute holding fieldname)
set attrVal $FME_Attributes(...name of list attribute holding value)
set FME_Attributes($attrName) $attrVal
I know I'm being sketchy here but hopefully this is enough to get someone
going. Again, only necessary if the data volumes are a bit large, as the
non-Tcl approach ends up using some "blocking" transformers that will need to
pile up all the data, whereas a Tcl approach can deal with each feature as it
goes by...
Dale
----------------------------------------------------------------------
Dale Lutz Safe Software Inc. [EMAIL PROTECTED]
VP Development Surrey, BC, CANADA phone: (604) 501-9985
http://www.safe.com fax: (604) 501-9965
----------------------------------------------------------------------
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jason
> Birch
> Sent: Tuesday, November 22, 2005 4:20 PM
> To: [email protected]
> Subject: RE: [fme] List format
>
> In that example, I'd probably want to see the following as a result rather
> than a list:
>
> length = 7.3
> kind = 'paved'
> lanes = 2
>
> Anyway...
>
> I would approach this as follows:
>
> - Counter to create unique attribute for each record
> - Split the datastream (One to AttributeRemover, one to ListRemover)
> - Stream 1 (AttributeRemover)
> - AttributeRemover (get rid of extras)
> - ListExploder to get separate features for each list item
> - AttributeCreator setting &fieldname = &fieldname
> - AttributeRemover (get rid of extras)
> - AttributeAccumulator (group by the Counter)
> - attach to FeatureMerger Supplier port
> - Stream 2 (ListRemover)
> - ListRemover to get rid of the list (which we redefine in the earlier
> step
> - attach to FeatureMerger Requestor port
> - ListSorter by the list element index generated by the ListExploder to
> make sure that original order is maintained
>
> This leaves you with some undesirable elements in the list. I'm not sure
> how you would clean these up. Also, the AttributeCreator does not
> translate the &fieldname value for you, so the workspace is a bit
> confusing unless you know what it's doing.
>
> Example attached.
>
> Jason
>
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of
> [EMAIL PROTECTED]
> Sent: Tuesday, November 22, 2005 14:37
> To: [email protected]
> Subject: [fme] List format
>
>
>
> Hi group,
>
> I have a lot of data in this list format:
>
> somelist{0}.fieldname = 'length'
> somelist{0}.fieldvalue = 7.3
> somelist{1}.fieldname = 'kind'
> somelist{1}.fieldvalue = 'paved'
> somelist{2}.fieldname = 'lanes'
> somelist{2}.fieldvalue = 2
>
>
> I want to convert into this list format:
> somelist{0}.length = 7.3
> somelist{1}.kind = 'paved'
> somelist{2}.lanes = 2
>
> In other words, I want to convert an attribute value into an attribute
> name. Which is the best strategy to accomplish this task in Workbench
> and/or FME functions and factories?
>
>
> Thanks to help me,
>
> Jean-François Beaudry
> Technicien en géomatique
>
> Hydro-Québec
> Géomatique, relevés techniques et gestion des données
> Direction - Environnement et services techniques
> Direction principale - Expertise
> Place Dupuis
> 9e étage Tél. : (514) 840-3000,
> 855, rue Sainte-Catherine Est poste 4230
> Montréal (Québec) H2L 4P5 Téléc. : (514) 840-4233
> [EMAIL PROTECTED] http://www.hydroquebec.com
> <http://www.hydroquebec.com>
>
>
> Get the maximum benefit from your FME, FME Objects, or SpatialDirect via
> our Professional Services team. Visit www.safe.com/services for details.
> Yahoo! Groups Links
>
>
>
>
Get the maximum benefit from your FME, FME Objects, or SpatialDirect via our
Professional Services team. Visit www.safe.com/services for details.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/fme/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/