Hi, I'm Ask INFA!
What would you like to know?
ASK INFAPreview
Please to access Ask INFA.

Table of Contents

Search

  1. Preface
  2. Working with Transformations
  3. Address Validator Transformation
  4. Aggregator Transformation
  5. Association Transformation
  6. Bad Record Exception Transformation
  7. Case Converter Transformation
  8. Classifier Transformation
  9. Cleanse transformation
  10. Comparison Transformation
  11. Custom Transformation
  12. Custom Transformation Functions
  13. Consolidation Transformation
  14. Data Masking Transformation
  15. Data Masking Examples
  16. Decision Transformation
  17. Duplicate Record Exception Transformation
  18. Dynamic Lookup Cache
  19. Expression Transformation
  20. External Procedure Transformation
  21. Filter Transformation
  22. HTTP Transformation
  23. Identity Resolution Transformation
  24. Java Transformation
  25. Java Transformation API Reference
  26. Java Expressions
  27. Java Transformation Example
  28. Joiner Transformation
  29. Key Generator Transformation
  30. Labeler Transformation
  31. Lookup Transformation
  32. Lookup Caches
  33. Match Transformation
  34. Match Transformations in Field Analysis
  35. Match Transformations in Identity Analysis
  36. Merge Transformation
  37. Normalizer Transformation
  38. Parser Transformation
  39. Rank Transformation
  40. Router Transformation
  41. Sequence Generator Transformation
  42. Sorter Transformation
  43. Source Qualifier Transformation
  44. SQL Transformation
  45. Using the SQL Transformation in a Mapping
  46. Stored Procedure Transformation
  47. Standardizer Transformation
  48. Transaction Control Transformation
  49. Union Transformation
  50. Unstructured Data Transformation
  51. Update Strategy Transformation
  52. Weighted Average Transformation
  53. XML Transformations

Transformation Guide

Transformation Guide

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 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 ports.
The mapping contains the following components:
  • Source definition.
    The source is a delimited flat file. Configure the source to pass rows of a flat file as a string to the Java transformation. The source file has 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 on the Java Code tab.
    Use the Import Packages tab of the Java Code to import the java package. Enter the following code on the Import Packages tab:
    import java.util.StringTokenizer;
    Use the On Input Row tab of the Java Code tab to read each row of data from a string and pass the data to output ports. Enter the following code on the On Input Row tab to retrieve the first two columns of data:
    StringTokenizer st1 = new StringTokenizer(row,","); f1 = st1.nextToken(); f11= st1.nextToken();
  • Target definition
    . Configure the target to receive rows of data from the Java Transformation. After you run a workflow that contains the mapping, the target contains two columns of data. The target file has the following data:
    1a,2a 1b,2b 1c,2c 1d,2d

0 COMMENTS

We’d like to hear from you!