Announcement Announcement Module
Collapse
No announcement yet.
Fixed Length file size Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fixed Length file size

    Hello,

    Is it possible to configure in the job file the line length of a flat file?
    eg in the FixedLengthTokenizer:

    <bean id="fixedFileTokenizer"
    class="org.springframework.batch.item.file.transfo rm.FixedLengthTokenizer">
    <property name="names" value="ISIN, Quantity, Price, Customer" />
    <property name="columns" value="1-12, 13-15, 16-20, 21-29" />
    <property nalme="length" value="29" />
    </bean>

    I'd like to fix the length line value in order to validate the file before parsing it.
    Can someone have any idea about it?
    Thanks

  • #2
    Just to clarify, do you mean the length of the line, (number of characters per line) or the length of the file (number of lines per file) ?

    Comment


    • #3
      I mean the length of the line (number of characters per line).
      In my case, the flat file needs to have lines of 200 characters.
      If one line doesn't check, the flat file has to be rejected.

      Comment


      • #4
        I may be misunderstanding, but doesn't the current implementation handle this? If the line size doesn't line up with the columns configured, it will throw a FlatFileParsingException, with the original line. Assuming you have configured your job to fail for this scenario, either by setting it as a failure causing exception if your'e using the SkipLimitFactoryBean, or by using a factory bean that doesn't allow skips.

        Comment


        • #5
          I need to validate the length of the line before formatting it with FixedLengthTokenizer. For example, if the line is less than 100 chars I don't want to continue.

          Or maybe someting like FixedLengthImportJobFunctionalTests....

          Some suggest?

          Comment


          • #6
            Right, but if you configure the FixedLengthTokenizer with columns that add up to 100, and you give a line that is more or less than that, it should throw an exception.

            Comment


            • #7
              No. It never throw an exception when the line is more or less.

              I'm using the version 1.0.1.RELEASE. (Too I've checked with the trunk)

              Comment

              Working...
              X