Coder Social home page Coder Social logo

geosander / fme-listkeyvaluepairextractor Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 40 KB

Custom transformer for FME® that enables a user to extract key-value pairs in lists as new attributes

License: GNU General Public License v3.0

fme transformer custom-transformer lists keyvaluepair

fme-listkeyvaluepairextractor's Introduction

FME® ListKeyValuePairExtractor

About

The ListKeyValuePairExtractor creates new attributes based on a list of keys (attribute names) and a list of values.
For example, a feature might contain the following list elements:

list{0}.name = 'StringData'
list{0}.data = 'Test Value'
list{1}.name = 'IntData'
list{1}.data = 32536
list{2}.name = 'FloatData'
list{2}.data = 23.67

If the user sets the Attribute Name List to list{n}.name and the Attribute Value List to list{n}.data, the transformer will add the following attributes to the output feature:

StringData = 'Test Value'
IntData = 32536
FloatData = 23.67

IMPORTANT

In the example above, you can fill in any integer for list element n. Due to the fact that FME does not support nested lists as an input parameter for custom transformers, you will actually have to specify it as a list attribute, using FME's List Element Selection dialog.
This means you can select regular attributes for the Attribute Name List and Attribute Value List parameters, but that will result in an error. It also means that if you have a basic unnested list, the index you specify does not matter. The ListKeyValuePairExtractor will simply fetch the complete list.

For example, if you want to use all the values in list{}.name as your Attribute Name List, you could set the input parameter to list{0}.name. If there are 3 elements in this list, the transformer will fetch list{0}.name, list{1}.name and list{2}.name. But this will also be the case if you set it to list{2}.name, for example.

However, if you want to use all the values of list{}.nestedlist{}, the index of the parent list{} matters and should exist! For example, if you set the Attribute Name List parameter to list{3}.nestedlist{0}, only the nestedlist{} elements within list{3} will be used.

Please note that the created attributes will not be exposed. You can use an AttributeExposer afterwards to achieve that.

Notes

  • Also available on FME Hub for convenient installation.
  • This transformer has been tested on Python 2.7 and 3.4.
  • Released under GNU General Public License v3.0.
  • If you notice a bug or desire a new feature, please contact me. Or make a pull request!
  • The test workspace is used for testing and provides some examples.

Usage

Attribute Name List
Specify the list attribute that should be used to extract the attribute names (keys). The list can have missing elements (in which case no attribute will be written), but the list should be in the same order as the Attribute Value List. Please read the overview section of this documentation for more information.

Attribute Value List
Specify the list attribute that should be used to extract the attribute values. If a value is missing or null, a warning will be shown in the log. The value list does not need to be of the same size as the Attribute Name List, but if the created pairs should match, the list has to be in the same order. Please read the overview section of this documentation for more information.

Conflict Resolution
If one or more of the Attribute Name List elements already exist as a feature attribute, setting this value to "Keep Original Attributes" will prevent the attribute values from being overwritten by the Attribute Value List elements.

fme-listkeyvaluepairextractor's People

Contributors

geosander avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.