uniVocity / univocity-parsers

uniVocity-parsers is a suite of extremely fast and reliable parsers for Java. It provides a consistent interface for handling different file formats, and a solid framework for the development of new parsers.
917 stars 252 forks source link

version 2.8.4: FixedWidthFields.keepPaddingOn not working #405

Closed vvalencia-cl closed 4 years ago

vvalencia-cl commented 4 years ago

Hi. First of all, thanks for this library.

Maybe I'm doing something wrong, but this is not working for me:

import com.univocity.parsers.fixed.FieldAlignment
import com.univocity.parsers.fixed.FixedWidthFields
import com.univocity.parsers.fixed.FixedWidthParser
import com.univocity.parsers.fixed.FixedWidthParserSettings

val fields = FixedWidthFields()
fields.addField("padding", 4, FieldAlignment.RIGHT, '0')
    .addField("text", 4, FieldAlignment.LEFT, ' ')
fields.keepPaddingOn("padding", "text")

val settings = FixedWidthParserSettings(fields)
settings.keepPadding = true

val parser = FixedWidthParser(settings)

println(parser.parseLine("0000abcd")?.contentToString())
println(parser.parseLine("0000    ")?.contentToString())

I've tried with FixedWidthParserSettings.keepPadding and it doesn't working either

The output of this snippet results in:

[null, abcd]
[null, null]

But it should be:

[0000, abcd]
[0000,     ]

Using dependency: com.univocity:univocity-parsers:2.8.4

jbax commented 4 years ago

Thanks for reporting this. I've fixed it and released version 2.8.5-SNAPSHOT for you to check.

Thank you for using our parsers!

vvalencia-cl commented 4 years ago

Thanks for reporting this. I've fixed it and released version 2.8.5-SNAPSHOT for you to check.

Thank you for using our parsers!

It worked. Thank you so much!