Table of Contents

Search

  1. Preface
  2. Introduction to Informatica Data Engineering Integration
  3. Mappings
  4. Mapping Optimization
  5. Sources
  6. Targets
  7. Transformations
  8. Python Transformation
  9. Data Preview
  10. Cluster Workflows
  11. Profiles
  12. Monitoring
  13. Hierarchical Data Processing
  14. Hierarchical Data Processing Configuration
  15. Hierarchical Data Processing with Schema Changes
  16. Intelligent Structure Models
  17. Blockchain
  18. Stateful Computing
  19. Appendix A: Connections Reference
  20. Appendix B: Data Type Reference
  21. Appendix C: Function Reference

Example: Add an ID Column to Nonpartitioned Data

Example: Add an ID Column to Nonpartitioned Data

Your organization runs a solar thermal power system that uses sensors to monitor the system's health. Currently, each sensor is identified by its location. Instead, you want to identify each sensor using an ID to simplify future analytics on the data.
You collect the following data on sensor readings:
SensorLocation
LastReadingTime
Area A
7/9/2019 11:36:09
Area B
7/9/2019 16:43:42
Area C
7/9/2019 13:23:53
To add an ID column and assign ID values to each sensor, complete the following steps:
Step 1. Create a Python transformation.
Create a passive Python transformation.
Step 2. Pass data to the Python transformation.
Pass data from upstream transformations in the mapping to the Python transformation.
After you pass the data to the Python transformation, the Python transformation contains the following input ports:
  • SensorLocation
  • LastReadingTime
Step 3. Create output ports.
Use the Ports tab in the Python transformation to create the output port
SensorID_out
to represent the ID column.
Additionally, create the following output ports to pass incoming data to downstream transformations:
  • SensorLocation_out
  • LastReadingTime_out
Step 4. Set the ID value for each row.
On the On Input tab, set the ID value for each row that is processed and write the data to the output ports using the following code:
SensorID="".join(str(x) for x in map(ord, SensorLocation)) SensorID_out = SensorID SensorLocation_out = SensorLocation LastReadingTime_out = LastReadingTime
Step 5. Run the mapping.
If the output ports in the Python transformation are linked directly to a Write transformation, the target contains the following data after you run the mapping:
SensorID_out
SensorLocation_out
LastReadingTime_out
65114101973265
Area A
7/9/2019 11:30:00
65114101973266
Area B
7/9/2019 11:35:00
65114101973267
Area C
7/9/2019 11:40:00

0 COMMENTS

We’d like to hear from you!