spring-batch-extensions icon indicating copy to clipboard operation
spring-batch-extensions copied to clipboard

Read columns as arrays

Open LiveNathan opened this issue 2 years ago • 4 comments

Hello! The second worksheet of every one of my workbooks has four columns with 24,000 rows. Ideally, I'd like to read in both sheets and each column needs to eventually exist as an array. Since this project converts each row to an object, is there a way to handle my case with columns to arrays?

2023-07-06 at 09 14 48@2x

LiveNathan avatar Jul 06 '23 14:07 LiveNathan

We generally read rows, which are represented as an array. But you want the columns as arrays?

mdeinum avatar Oct 02 '23 13:10 mdeinum

We generally read rows, which are represented as an array. But you want the columns as arrays?

Exactly. Right now I have a workaround that reads in a row then adds each column as a new element in each array, but it would be better to just read in the entire array at once.

LiveNathan avatar Oct 02 '23 18:10 LiveNathan

Excel is row oriented and so is the Apache POI library, so the only way to retrieve all values for the columns is to iterate over the rows. So I'm not sure how to approach this without pulling everything apart.

The quickest workaround would be to create a a writer that writes to the array(s) you need, stores it somewhere (maybe in the jobcontext) then have another step operate on that array.

mdeinum avatar Oct 02 '23 18:10 mdeinum

Ok, thanks. That is how I'm currently handling it.

LiveNathan avatar Oct 02 '23 18:10 LiveNathan