Skip to main content
Open

Easy Way to Create Structured List from Multiple CSV

Related products:Transformers
rylanatsafe
siennaatsafe
david_r
takashi
jdh
+5
  • rylanatsafe
    rylanatsafe
  • siennaatsafe
    siennaatsafe
  • david_r
    david_r
  • takashi
    takashi
  • jdh
    jdh
  • j.botterill
    j.botterill
  • bwn
    bwn
  • denizturan1985
    denizturan1985
  • esietinga
    esietinga
  • tkaufmann
    tkaufmann

takashi
Influencer
There are cases where users need to create a structured list after splitting two or more attributes corresponding each other.
e.g.
Source attributes:
Names = 'aaa,bbb,ccc'
Types = 'x,y,z'
Values = '1,2,3'
Required list:
_list{0}.Name = 'aaa', _list{1}.Name = 'bbb', _list{2}.Name = 'ccc'
_list{0}.Type = 'x', _list{1}.Type = 'y', _list{2}.Type = 'z'
_list{0}.Value = '1', _list{1}.Value = '2', _list{2}.Value = '3'

To ease that,
- add an parameter (optional) to the AttributeSplitter, so that the user can specify component (member) name that will be added to the resulting list name.
and/or
- enhance the functionality of ListRenamer (List Action: Rename), so that the user can add a component (member) name to the selected list name optionally. i.e. allow set "_newName{}.member" for "_oldName{}".

5 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • September 11, 2017

I would also like to see an enhancement to the ListRenamer to turn a simple list into a structured list.


takashi
Influencer
  • Author
  • September 12, 2017

Yes, hope the enhancement will be done.

I found two workarounds except Python/Tcl scripting so far.

1. Split the source comma-separated values with AttributeSplitters, then rename the lists with a BulkAttributeRenamer.

'

2. Create a JSON from the source comma-separated values, then flatten it into a structured list.

'

JSON Template Expression

{ "_list" : [ let $types := fn:tokenize(fme:get-attribute("Types"), '\\s*,\\s*') let $values := fn:tokenize(fme:get-attribute("Values"), '\\s*,\\s*') for $name at $i in fn:tokenize(fme:get-attribute("Names"), '\\s*,\\s*') return { "Name" : $name, "Type" : $types[$i], "Value" : $values[$i] } ] } Anyway you need to expose the resulting lists and hide/remove unnecessary attributes, it's annoying.

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • September 12, 2017
In my particular case I'm not starting with a csv, the data is already in a simple list and I need it to become a structured list.

 


takashi
Influencer
  • Author
  • September 12, 2017
@jdh, starting with multiple simple lists, JSON approach can also be applied, but I would use the BulkAttributeRenamer. If the number of components is just two, the ListZipper from FME Hub can also be used alternatively.

 

How do you resolve the case now?

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • September 12, 2017
I was able to create a workaround that avoided the need for a structured list,and filed a bug as case C130961. (Using the Deaggregator with the list attribute to explode being a simple list does not make for happy results)

 

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings