Results 1 to 5 of 5

Thread: FlatFile reading

  1. #1

    Default FlatFile reading

    I have a flat file that contains header,column names, data and footer in the following format

    Header|headercol1|headercol2|headercol3|headercol4
    column1|column2|column3.......
    data1|data2|data3..........
    .
    .
    .
    Trailer|RecordCount:XX


    1. Columns in header apply to all the data, so I need to set the values in data beans.
    2. Ignore the second row.
    3. Validate if data count = trailer data count, if not fail the process.


    Any suggestion on how to accoplish this?

    Thanks,
    Nitty

  2. #2

    Default

    Can someone give me an idea(s) to do this?

  3. #3
    Join Date
    Feb 2008
    Posts
    488

    Default

    Use PatternMatchingCompositeLineMapper to handle the different line types differently. When you handle the header, store its data into the Step ExecutionContext so that it can be used in the future (and saved in case of an error). For each data item handled read the necessary things from the Step ExecutionContext. Also, update the aggregate information in the Step ExecutionContext (number of records etc) so you can keep running totals (again, that are saved in case of an error). When you process the trailer, you can read from the Step ExecutionContext and verify the information.

    Give that a shot. All of these concepts are detailed in the reference documentation. If you have specific questions about how to do these things, let me know.

  4. #4

    Default

    Thanks.
    How do I get a handle (inject) stepExection inside the processor - one of the previous post mentioned <quote> You can also inject the step execution into a step-scoped component with a late binding expression #{stepExecution}.
    </quote>

    Not sure how to do this - can you throw some light?

  5. #5

    Default

    Quote Originally Posted by Nitty View Post
    Thanks.
    How do I get a handle (inject) stepExection inside the processor - one of the previous post mentioned <quote> You can also inject the step execution into a step-scoped component with a late binding expression #{stepExecution}.
    </quote>

    Not sure how to do this - can you throw some light?
    you could try the following

    Code:
    private StepExecution stepExecution;
    
    	@BeforeStep
    	public void saveStepExecution(StepExecution stepExecution) {
    		this.stepExecution = stepExecution;
    	}
    and put scope step into your app context for that reader

    hope that helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •