Skip header, body and footer lines from file on Spring Batch
14,223
Nope. linesToSkip
(as you wrote) just skip the first linesToSkip
lines.
You have to write your own reader using multiorder-line example (or this post) as base and manage skip first line of each block manually
Comments
-
clbcabral almost 2 years
I have this specifically file:
H;COD;CREATION_DATE;TOT_POR;TYPE H;001;2013-10-30;20;R D;DETAIL_VALUE;PROP_VALUE D;003;3030 D;002;3031 D;005;3032 T;NUM_FOL;TOT T;1;503.45
As you can see, it has header/body/footer lines. I'm looking for a ItemReader that skip these lines. I've done this ItemReader below who identify those lines, using PatternMatchingCompositeLineMapper.
<bean id="fileReader" class="org.springframework.batch.item.file.FlatFileItemReader"> <property name="resource" ref="myFileReference" /> <property name="lineMapper"> <bean class="org.springframework.batch.item.file.mapping.PatternMatchingCompositeLineMapper"> <property name="tokenizers"> <map> <entry key="H*" value-ref="headerLineTokenizer"/> <entry key="D*" value-ref="bodyLineTokenizer"/> <entry key="T*" value-ref="footerLineTokenizer"/> </map> </property> <property name="fieldSetMappers"> <map> <entry key="H*" value-ref="headerMapper"/> <entry key="D*" value-ref="bodyMapper"/> <entry key="T*" value-ref="footerMapper"/> </map> </property> </bean> </property> </bean>
I tried to add linesToSkip property equals 1, but it only skipped the header line. Is there a way to skip the first line of each block(header, body and footer)?
Thks.