Results 1 to 3 of 3

Thread: Pivoting Items

  1. #1

    Default Pivoting Items

    I have a flat file source with format of field1|field2|field3. Rather than writing out a single item for each input, I would like to pivot the input record so that my output file contains:

    field1
    field2
    field3

    I understand how to implement an ItemProcessor to transform an Input Item into an Output Item. Can my Output Item be a List? The ItemWriter#write takes a List of items to write. I would now have a List of Lists. Am I going to run into any issues here?

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    366

    Default

    That depends on your LineAggregator (assuming you want to write a flat file) implementation. That LineAggregator#aggregate(T item) in your case would get a List for each call. If you format that list into a String with line breaks in it causing it to be one line per element in the List...all should be just fine.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  3. #3

    Default

    Worked great! Thanks.

Posting Permissions

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