Skip to main content
Hi,

 

I'm having trouble restructing my (aspatial) data from what I can best describ as multiple rows per uninqe identifer each containing a feild name and respective value to a single row per feature per feature where there field name values become columns. The example below probably explains this better:

 

 

---INPUT----

 

ID,Field,Value

 

1,FieldA,Cow

 

1,FieldC,Sheep

 

2,FieldA,Dog

 

2,FieldB,Mouse

 

2,FieldC,Cow

 

 

---DESIRED OUTPUT---

 

ID,FieldA,FieldB,FieldC

 

1,Cow,,Sheep

 

2,Dog,Mouse,Cow

 

 

Does anyone have any tips as to how this is best don? Aggreagting is based on the ID is easy, but manipulating the resultant list items into the format of the desired output is eluding me.

 

 

Regards. Rob.

 

You can use the excel writer technique described below (Pratap's question).

 

 

ID = xlsx_row_id.

 

@(Value(@Value(Field)) =@Value(Value)

 

Input written to csv schema for exposer.

 

need modern excelwirter for that though (i use fme2014sp2 and newer)
U can

 

listbuilder on ID.

 

Listelementconter.

 

Attributecreator for a index.

 

 

 

Listindexer in a loop/ customtransformer

 

 

 

 

Like in previous suggestion, you must create a csv from the input data to use as a schema for the exposer. (import values)
Hi Rob,

 

 

I would use the BulkAttributeRenamer and the Aggregator.

 

BulkAttributeRenamer

 

 

 

Aggregator

 

Group By: ID

 

Mode: Attribute Only

 

Keep Input Attribute: Yes

 

 

Then, you can expose required attribute names (FieldA, FieldB, and FieldC) with the AttributeExposer.

 

 

Takashi
that techniques is the same as just creating attributes and grouping them:

 

Attribute_name = @Value(@Value(Field))

 

Attribute_value = @Value(value).

 

Don't need a renamer for that.

 

 

You then have a table where FIELDB is missing on the first row.

 

My techniques don't have that flaw.

 

(unless htat is not a issue....)

 

 

Also i would write out the table to a csv (or other format)  and then use it as schema.

 

Unless you like to manualy expose attributes.
Gio, Takashi,

 

 

Thanks both for your responses. My final approched used Takashi solution, but the AttributeCreator in place as the BulkAttributeRenamer as suggested by Gio Both produce the same result though.

 

 

Regards. Rob.

Reply