Triming column headers in flatfiles
Hi,
I got a flatfile (see attached). In the flatfile all lines are padded to 180 characters. Trimming the data fields in the data records is no problem using the Tokenizer 'DelimitedLineTokenizer'. Unfortunatly it doesn't trim the column headers (on top of the file), thus in my mapper when I try to set my FieldSet using...
mtm.setDate(fieldSet.readString(quot;DATE_quot;)); // note: Date is a string field
..it doesn't work because the DATE_ column header is padded with the spaces necessary to make the 180 chars long.
Any ideas how to solve this (without using the 'mtm.setDate(fieldSet.readString(4));' option).....i.e. trim the column headers...
Thanks,
Noel.
You can set the header nmes explicitly in the tokenizer. I assume you are using 1.x because converting the first line to header names is a feature that was removed in 2.0. The assumption behind that is that if you don't know the header names, you can't write you FieldSetMapper anyway, so there wasn't actually much value in the feature (and it caused problems with more complex use cases).
You can set the lt;property name=quot;linesToSkipquot; value=quot;1quot; /gt; for FlatFileItemReader.
value=1 skip first line
value=2 line etc |