Skip to main content

I received a text file that has descriptions about features as follows:

ADD FUSE 9911 {

PHASES =1;

PORT_A = <123>;

PORT_B = <234>;

ATTRIBUTE[county] = "SEATTLE";

ATTRIBUTE[street] = "MAIN ST";

ATTRIBUTE[facility_id] = "1324";

ATTRIBUTE[feeder_id_1] = "FD1";

ATTRIBUTE[feeder_id_2] = "Null";
}

;

ADD 1p_conductor 125623 {

...

};

Now, how to create individual features out of these?

1. I tried Aggregator:


groupby - text_line_data

Separator character: };

2. Tried to loop text_line_data and break whenever "};" is encountered. But both didn't work.

Is there a simple way to do this?

Read the text file into one attribute.

Use the AttributeSplitter and split on }; to create a list.

Use the ListExploder to generate objects per list item.

That will generate the different features.

Next you want to split each feature again on ; to get the different attributes in a list.


@vindastra

That will ignore the first itemname..

Use a txtreader read by row.

Ue a variableretriever and searchers

The not matched will give (in order). the attributes and value rows.

Test for not empty rows and rows witt "neither ";" nor "}" (newlines/carriagereturns etc.) and then searchers again.

Then..well.. here is example..


Does example 4 on this page help?

https://knowledge.safe.com/articles/687/using-fme-to-read-or-write-comma-separated-value-c.html


What's the best transformation to make a value pair (attribute name=attribute value) stored in a list element _attribute(1) into a feature attribute name and attribute value. e.g. see screenshot. So a feature with _attribute(3) with value "iso=0" will have a new attribute named "iso" and a value of "0". 2016-03-31-07-21-57-fme-data-inspector.png


I tried the KeyValueAttributeCreator but it seems by Key,Value pair delimiter which is a LF or \\n is not being read.


What's the best transformation to make a value pair (attribute name=attribute value) stored in a list element _attribute(1) into a feature attribute name and attribute value. e.g. see screenshot. So a feature with _attribute(3) with value "iso=0" will have a new attribute named "iso" and a value of "0". 2016-03-31-07-21-57-fme-data-inspector.png

Hi @geospatiallover, I think a quick way is to remove "<any string>=" from the values, then rename the list elements. e.g.


@takashi....thanks. I started with a renamer after my splitter and got lost with putting an expression on the output value. Thanks for your help once again. Strings have always been my weakness in FME.


Just a thought, what if the attribute name keeps changing? This is metadata for UAV collected JPEGs and once another camera is used then the attribute schema will change. Any suggestions @takashi? I sure hope Safe would have a JPEGExif writer soon. Not a lot of voters yet on this idea.


Just a thought, what if the attribute name keeps changing? This is metadata for UAV collected JPEGs and once another camera is used then the attribute schema will change. Any suggestions @takashi? I sure hope Safe would have a JPEGExif writer soon. Not a lot of voters yet on this idea.

You can use the KeyValueAttributeCreator after you have concatenated the list elements with a specific delimiter string. e.g. using the ListConcatenator.


You can use the KeyValueAttributeCreator after you have concatenated the list elements with a specific delimiter string. e.g. using the ListConcatenator.

Thanks again!


Reply