SlideShare a Scribd company logo
1 of 17
Download to read offline
CONNECT. TRANSFORM. AUTOMATE.
Beyond 49x Transformers: Don't be afraid
of (the) Python!
Tino Miegel
Software Engineer
Introduction
!  Employed at con terra GmbH
since 2009
!  Spatial ETL Professional
Services
!  FME Certified Trainer since
2010
!  FME Certified Professional
since 2013
CONNECT. TRANSFORM. AUTOMATE.
What is Python?
Python is an interpreted, object-oriented, high-level
programming language with dynamic semantics. Its high-level
built in data structures, combined with dynamic typing and
dynamic binding, make it very attractive for Rapid Application
Development, as well as for use as a scripting or glue
language to connect existing components together. Python's
simple, easy to learn syntax emphasizes readability and
therefore reduces the cost of program maintenance. Python
supports modules and packages, which encourages program
modularity and code reuse. The Python interpreter and the
extensive standard library are available in source or binary
form without charge for all major platforms, and can be freely
distributed.
Source: https://www.python.org/doc/essays/blurb/
What is Python?
!  Interpreted language
!  With dynamic typing
!  Extensive standard library
!  Available without charge for all major platforms
!  Freely distributable
Included in every FME Desktop and
FME Server
Why use Python?
!  Easy to learn
!  Very „googlable“
!  Thousands of additional libraries available
!  Fast
!  Comprehensive usage e.g.
!  Esri ArcGIS
!  Blender
Hello World in Python
#HelloWorld.py
print("Hello World!")
>>>
Hello World!
>>>
Where to find Python in FME
!  Startup and Shutdown
Python Script
" Navigator -> Workspace
Parameters -> Advanced
Demo 1 – Log Statistics
Live Demo
!  Use a Shutdown Python Script to log statistic
information into a central file or database
!  Access several FME runtime variables via the fme
module:
	
  import	
  fme	
  
	
  runtime	
  =	
  fme.elapsedRunTime	
  
	
  >>>	
  	
  12.3	
  
Where to find Python in FME
!  PythonCreator and PythonCaller transformers
" QuickAdd or Transformer Gallery
Demo 2 – Handle Dynamic
Attributes
!  Handle features with an arbitrary number of
attributes
!  Leave features with a defined attribute set
!  Name
!  ID
!  Create Attribute Container Features for each
attribute with
!  referenceFID
!  AttributName
!  AttributValue
Live Demo
Where to find Python in FME
!  Scripted Python Parameter
!  Navigator -> User Parameters -> Private
Parameters
!  Has to end with a return statement
Change Default Interpreter
!  Python Options (Custom Interpreter)
" Tools -> FME Options -> Runtime
!  Why?
!  Need other python version <2.7
!  Utilize external python packages from a different
interpreter, e.g. arcpy
Order of Evaluation
1.  Scripted Python Parameter
2.  Startup Python Script
3.  Workspace logic
1.  Reader
2.  Transformer chain
3.  Writer
4.  Shutdown Python Script
Advanced Usage - FMEObjects
!  Make sure to select
„Install FME SDK“ on
installation of FME
!  API documentation
!  <FMEHOME>fmeobjects
pythonapidoc
Demo 3: WorkspaceRunner
!  Use the Python WorkspaceRunner interface to run
your FME workspaces:
!  run(workspace)	
  
!  withParameters(workspace, parameters)
!  promptRun(workspace)
Live Demo
Advanced Usage – Plugin SDK
!  Code your own native transformer with Python
!  API documentation
!  <FMEHOME>pluginbuilderpythonapidoc
!  Sample (available in FME 2015 Beta builds)
!  <FMEHOME>pluginbuildersamplespython
Thank You!
!  Questions?
!  For more information:
!  Tino Miegel, t.miegel@conterra.de
@TMiegel
!  con terra GmbH, fme@conterra.de
!  Python and FME Basics
http://fmepedia.safe.com/articles/How_To/Python-
and-FME-Basics
CONNECT. TRANSFORM. AUTOMATE.

More Related Content

What's hot

Compiler.design.in.c.docs
Compiler.design.in.c.docsCompiler.design.in.c.docs
Compiler.design.in.c.docs
Abid Syed
 
Language translators
Language translatorsLanguage translators
Language translators
Aditya Sharat
 

What's hot (20)

Py Con 2009 Pumping Iron Into Python
Py Con 2009   Pumping Iron Into PythonPy Con 2009   Pumping Iron Into Python
Py Con 2009 Pumping Iron Into Python
 
Interpreters & Debuggers
Interpreters  &  DebuggersInterpreters  &  Debuggers
Interpreters & Debuggers
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in Compiler
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
 
What is new in Python 3.9
What is new in Python 3.9What is new in Python 3.9
What is new in Python 3.9
 
Python Crash Course
Python Crash CoursePython Crash Course
Python Crash Course
 
Language processor
Language processorLanguage processor
Language processor
 
Compiler interpreter and_bootstrapping
Compiler interpreter and_bootstrappingCompiler interpreter and_bootstrapping
Compiler interpreter and_bootstrapping
 
Compiler.design.in.c.docs
Compiler.design.in.c.docsCompiler.design.in.c.docs
Compiler.design.in.c.docs
 
compiler vs interpreter
compiler vs interpretercompiler vs interpreter
compiler vs interpreter
 
web programming Unit VIII complete about python by Bhavsingh Maloth
web programming Unit VIII complete about python  by Bhavsingh Malothweb programming Unit VIII complete about python  by Bhavsingh Maloth
web programming Unit VIII complete about python by Bhavsingh Maloth
 
Language translators
Language translatorsLanguage translators
Language translators
 
Eclipse Day India 2015 - Unleashing the Java 8 Tooling in Eclipse
Eclipse Day India 2015 - Unleashing the Java 8 Tooling in EclipseEclipse Day India 2015 - Unleashing the Java 8 Tooling in Eclipse
Eclipse Day India 2015 - Unleashing the Java 8 Tooling in Eclipse
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
The compilation process
The compilation processThe compilation process
The compilation process
 
Compilation v. interpretation
Compilation v. interpretationCompilation v. interpretation
Compilation v. interpretation
 
Language Translator ( Compiler)
Language Translator ( Compiler)Language Translator ( Compiler)
Language Translator ( Compiler)
 
Python indroduction
Python indroductionPython indroduction
Python indroduction
 
Computer Language Translator
Computer Language TranslatorComputer Language Translator
Computer Language Translator
 
Python for All
Python for All Python for All
Python for All
 

Similar to Beyond 49x Transformers: Don't be afraid of (the) Python!

Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
Kanchilug
 
session5-Getting stated with Python.pdf
session5-Getting stated with Python.pdfsession5-Getting stated with Python.pdf
session5-Getting stated with Python.pdf
AyushDutta32
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
Manohar k
 

Similar to Beyond 49x Transformers: Don't be afraid of (the) Python! (20)

Creating Custom Solutions with FME and Python
Creating Custom Solutions with FME and PythonCreating Custom Solutions with FME and Python
Creating Custom Solutions with FME and Python
 
introduction of python in data science
introduction of python in data scienceintroduction of python in data science
introduction of python in data science
 
Creating Custom Solutions with FME and Python
Creating Custom Solutions with FME and PythonCreating Custom Solutions with FME and Python
Creating Custom Solutions with FME and Python
 
Introduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdfIntroduction to Python Unit -1 Part .pdf
Introduction to Python Unit -1 Part .pdf
 
Introduction to Python.pptx
Introduction to Python.pptxIntroduction to Python.pptx
Introduction to Python.pptx
 
python unit2.pptx
python unit2.pptxpython unit2.pptx
python unit2.pptx
 
Python quick guide1
Python quick guide1Python quick guide1
Python quick guide1
 
Python
PythonPython
Python
 
session5-Getting stated with Python.pdf
session5-Getting stated with Python.pdfsession5-Getting stated with Python.pdf
session5-Getting stated with Python.pdf
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python
PythonPython
Python
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
 
Chapter - 1.pptx
Chapter - 1.pptxChapter - 1.pptx
Chapter - 1.pptx
 
THE ULTIMATE GUIDE ON PYTHON
THE ULTIMATE GUIDE ON PYTHONTHE ULTIMATE GUIDE ON PYTHON
THE ULTIMATE GUIDE ON PYTHON
 
01 python introduction
01 python introduction 01 python introduction
01 python introduction
 
Session-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptxSession-1_Introduction to Python.pptx
Session-1_Introduction to Python.pptx
 
Python Course In Chandigarh
Python Course In ChandigarhPython Course In Chandigarh
Python Course In Chandigarh
 
Python-00 | Introduction and installing
Python-00 | Introduction and installingPython-00 | Introduction and installing
Python-00 | Introduction and installing
 
Cmpe202 01 Research
Cmpe202 01 ResearchCmpe202 01 Research
Cmpe202 01 Research
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptx
 

More from Safe Software

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Safe Software
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software
 
Introducing the New FME Community Webinar - Feb 21, 2024 (2).pdf
Introducing the New FME Community Webinar - Feb 21, 2024 (2).pdfIntroducing the New FME Community Webinar - Feb 21, 2024 (2).pdf
Introducing the New FME Community Webinar - Feb 21, 2024 (2).pdf
Safe Software
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Safe Software
 
Taking Off with FME: Elevating Airport Operations to New Heights
Taking Off with FME: Elevating Airport Operations to New HeightsTaking Off with FME: Elevating Airport Operations to New Heights
Taking Off with FME: Elevating Airport Operations to New Heights
Safe Software
 
Initiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance Strategy
Safe Software
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software
 

More from Safe Software (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action:  Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action:  Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
The Critical Role of Spatial Data in Today's Data Ecosystem
The Critical Role of Spatial Data in Today's Data EcosystemThe Critical Role of Spatial Data in Today's Data Ecosystem
The Critical Role of Spatial Data in Today's Data Ecosystem
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Mastering MicroStation DGN: How to Integrate CAD and GIS
Mastering MicroStation DGN: How to Integrate CAD and GISMastering MicroStation DGN: How to Integrate CAD and GIS
Mastering MicroStation DGN: How to Integrate CAD and GIS
 
Geospatial Synergy: Amplifying Efficiency with FME & Esri
Geospatial Synergy: Amplifying Efficiency with FME & EsriGeospatial Synergy: Amplifying Efficiency with FME & Esri
Geospatial Synergy: Amplifying Efficiency with FME & Esri
 
Introducing the New FME Community Webinar - Feb 21, 2024 (2).pdf
Introducing the New FME Community Webinar - Feb 21, 2024 (2).pdfIntroducing the New FME Community Webinar - Feb 21, 2024 (2).pdf
Introducing the New FME Community Webinar - Feb 21, 2024 (2).pdf
 
Breaking Barriers & Leveraging the Latest Developments in AI Technology
Breaking Barriers & Leveraging the Latest Developments in AI TechnologyBreaking Barriers & Leveraging the Latest Developments in AI Technology
Breaking Barriers & Leveraging the Latest Developments in AI Technology
 
Best Practices to Navigating Data and Application Integration for the Enterpr...
Best Practices to Navigating Data and Application Integration for the Enterpr...Best Practices to Navigating Data and Application Integration for the Enterpr...
Best Practices to Navigating Data and Application Integration for the Enterpr...
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
 
New Year's Fireside Chat with Safe Software’s Founders
New Year's Fireside Chat with Safe Software’s FoundersNew Year's Fireside Chat with Safe Software’s Founders
New Year's Fireside Chat with Safe Software’s Founders
 
Taking Off with FME: Elevating Airport Operations to New Heights
Taking Off with FME: Elevating Airport Operations to New HeightsTaking Off with FME: Elevating Airport Operations to New Heights
Taking Off with FME: Elevating Airport Operations to New Heights
 
Initiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance Strategy
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Beyond 49x Transformers: Don't be afraid of (the) Python!

  • 1. CONNECT. TRANSFORM. AUTOMATE. Beyond 49x Transformers: Don't be afraid of (the) Python! Tino Miegel Software Engineer
  • 2. Introduction !  Employed at con terra GmbH since 2009 !  Spatial ETL Professional Services !  FME Certified Trainer since 2010 !  FME Certified Professional since 2013 CONNECT. TRANSFORM. AUTOMATE.
  • 3. What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed. Source: https://www.python.org/doc/essays/blurb/
  • 4. What is Python? !  Interpreted language !  With dynamic typing !  Extensive standard library !  Available without charge for all major platforms !  Freely distributable Included in every FME Desktop and FME Server
  • 5. Why use Python? !  Easy to learn !  Very „googlable“ !  Thousands of additional libraries available !  Fast !  Comprehensive usage e.g. !  Esri ArcGIS !  Blender
  • 6. Hello World in Python #HelloWorld.py print("Hello World!") >>> Hello World! >>>
  • 7. Where to find Python in FME !  Startup and Shutdown Python Script " Navigator -> Workspace Parameters -> Advanced
  • 8. Demo 1 – Log Statistics Live Demo !  Use a Shutdown Python Script to log statistic information into a central file or database !  Access several FME runtime variables via the fme module:  import  fme    runtime  =  fme.elapsedRunTime    >>>    12.3  
  • 9. Where to find Python in FME !  PythonCreator and PythonCaller transformers " QuickAdd or Transformer Gallery
  • 10. Demo 2 – Handle Dynamic Attributes !  Handle features with an arbitrary number of attributes !  Leave features with a defined attribute set !  Name !  ID !  Create Attribute Container Features for each attribute with !  referenceFID !  AttributName !  AttributValue Live Demo
  • 11. Where to find Python in FME !  Scripted Python Parameter !  Navigator -> User Parameters -> Private Parameters !  Has to end with a return statement
  • 12. Change Default Interpreter !  Python Options (Custom Interpreter) " Tools -> FME Options -> Runtime !  Why? !  Need other python version <2.7 !  Utilize external python packages from a different interpreter, e.g. arcpy
  • 13. Order of Evaluation 1.  Scripted Python Parameter 2.  Startup Python Script 3.  Workspace logic 1.  Reader 2.  Transformer chain 3.  Writer 4.  Shutdown Python Script
  • 14. Advanced Usage - FMEObjects !  Make sure to select „Install FME SDK“ on installation of FME !  API documentation !  <FMEHOME>fmeobjects pythonapidoc
  • 15. Demo 3: WorkspaceRunner !  Use the Python WorkspaceRunner interface to run your FME workspaces: !  run(workspace)   !  withParameters(workspace, parameters) !  promptRun(workspace) Live Demo
  • 16. Advanced Usage – Plugin SDK !  Code your own native transformer with Python !  API documentation !  <FMEHOME>pluginbuilderpythonapidoc !  Sample (available in FME 2015 Beta builds) !  <FMEHOME>pluginbuildersamplespython
  • 17. Thank You! !  Questions? !  For more information: !  Tino Miegel, t.miegel@conterra.de @TMiegel !  con terra GmbH, fme@conterra.de !  Python and FME Basics http://fmepedia.safe.com/articles/How_To/Python- and-FME-Basics CONNECT. TRANSFORM. AUTOMATE.