Table of Contents

Search

  1. Preface
  2. Transformations
  3. Source transformation
  4. Target transformation
  5. Aggregator transformation
  6. Cleanse transformation
  7. Data Masking transformation
  8. Deduplicate transformation
  9. Expression transformation
  10. Filter transformation
  11. Hierarchy Builder transformation
  12. Hierarchy Parser transformation
  13. Hierarchy Processor transformation
  14. Input transformation
  15. Java transformation
  16. Java transformation API reference
  17. Joiner transformation
  18. Labeler transformation
  19. Lookup transformation
  20. Mapplet transformation
  21. Normalizer transformation
  22. Output transformation
  23. Parse transformation
  24. Python transformation
  25. Rank transformation
  26. Router transformation
  27. Rule Specification transformation
  28. Sequence Generator transformation
  29. Sorter transformation
  30. SQL transformation
  31. Structure Parser transformation
  32. Transaction Control transformation
  33. Union transformation
  34. Velocity transformation
  35. Verifier transformation
  36. Web Services transformation

Transformations

Transformations

Using Java code to parse a flat file

Using Java code to parse a flat file

You can develop Java code to parse a flat file. Use Java code to extract specific columns of data from a flat file of varying schema or from a JMS message.
For example, you want to read the first two columns of data from a delimited flat file. Create a mapping that reads data from a delimited flat file and passes data to one or more output fields.
The mapping contains the following components:
Source transformation
The source is a delimited flat file. Configure the source to pass each row as a single string to the Java transformation. The source file contains the following data:
1a,2a,3a,4a,5a,6a,7a,8a,9a,10a 1b,2b,3b,4b,5b,6b,7b,8b,9b 1c,2c,3c,4c,5c,6c,7c 1d,2d,3d,4d,5d,6d,7d,8d,9d,10d
Java transformation
Define the Java transformation functionality in the Java editor.
Use the On Input Row section of the Java editor to read each input row and pass the first two fields to the output field, outputRow. Enter the following code in the On Input Row section:
// Collect the first two fields of the row and output them into outputRow. String[] rowsSplit = row.split(",", 3); if (rowsSplit.length >= 2) { outputRow = rowsSplit[0] + "," + rowsSplit[1]; } generateRow();
Target transformation
Configure the target to receive the output field, outputRow, from the Java transformation. After you run the mapping, the target file has the following data:
1a,2a 1b,2b 1c,2c 1d,2d