Table of Contents

Search

  1. Preface
  2. Transformations
  3. Source transformation
  4. Target transformation
  5. Access Policy transformation
  6. Aggregator transformation
  7. B2B transformation
  8. Chunking transformation
  9. Cleanse transformation
  10. Data Masking transformation
  11. Data Services transformation
  12. Deduplicate transformation
  13. Expression transformation
  14. Filter transformation
  15. Hierarchy Builder transformation
  16. Hierarchy Parser transformation
  17. Hierarchy Processor transformation
  18. Input transformation
  19. Java transformation
  20. Java transformation API reference
  21. Joiner transformation
  22. Labeler transformation
  23. Lookup transformation
  24. Machine Learning transformation
  25. Mapplet transformation
  26. Normalizer transformation
  27. Output transformation
  28. Parse transformation
  29. Python transformation
  30. Rank transformation
  31. Router transformation
  32. Rule Specification transformation
  33. Sequence transformation
  34. Sorter transformation
  35. SQL transformation
  36. Structure Parser transformation
  37. Transaction Control transformation
  38. Union transformation
  39. Vector Embedding transformation
  40. Velocity transformation
  41. Verifier transformation
  42. 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

0 COMMENTS

We’d like to hear from you!