Results 1 to 4 of 4

Thread: database to flat file

  1. #1
    Join Date
    Sep 2012
    Posts
    4

    Default database to flat file

    Hello everyone,

    Is it possible to write the row count on the flat file along with the chunk size and also i have a amount column in a row i need to add them up in every page .when i go through the spring batch in action i think field extractor interface is one of the option .can anyone please help me in this .please suggest me what should i do ?is it possible to calculate the amount in every page ?

    Thanks in advance

  2. #2
    Join Date
    Oct 2012
    Location
    Madrid
    Posts
    20

    Default

    Hello satz,

    Of course, in the StepExecution bean you have the row.count value. To get it, first in the @BeforeStep get the StepExecution parameter and define a new variable in your process of type StepExecution (and @Autowired it). Then, you can use all the counters that the StepExecution manages.

    Hope to hep you. If you have any other question, please let me know.


    Regards,

  3. #3
    Join Date
    Sep 2012
    Posts
    4

    Default Can we add column data

    Hi maxjuiz,

    Thank you for your response ,so using StepExecution i can get the rowcount to be shown on flat file but what about the column data ,I have a column with the amount which have some have value on each row ,i need the sum of all for every chunk .how can i do that ? can you please suggest me

    Thank you ..

    Quote Originally Posted by maxjuiz View Post
    Hello satz,

    Of course, in the StepExecution bean you have the row.count value. To get it, first in the @BeforeStep get the StepExecution parameter and define a new variable in your process of type StepExecution (and @Autowired it). Then, you can use all the counters that the StepExecution manages.

    Hope to hep you. If you have any other question, please let me know.


    Regards,

  4. #4
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    349

    Default

    The easiest way to handle the aggregation you're talking about is going to be to write your own writer that wraps the FlatFileItemWriter. You can aggregate the records in each chunk there and delegate all actual writing work to the FlatFileItemWriter.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Posting Permissions

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