Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug with ragged right files #59

Merged
merged 1 commit into from
Dec 19, 2017
Merged

Conversation

amyskippy
Copy link
Contributor

This is just a small fix for a problem I encountered processing data dump files that were ragged right. These files were in a ragged right format where trailing fields were missing from some lines if no further fields contained data. I have learned this could have been caused if the data dumps were from a Cobol data formatted file (http://tech.wakayos.com/?p=293).

If the length of a line in a file falls short of providing a value for each field (ragged right file), the linePosition can end up equal to the length of the line. This doesn't cause a problem if this is the last field, but does pose a problem if there are additional fields to be checked.

On getting the value for the next field the linePosition ends up after the end of the line and throws an exception. The change makes sure that the linePosition is either at or below the end of the line length before trying to start the Substring function. This forces either the NullValue to be returned, or the exception defined a few lines below to be thrown.

If the length of a line in a file falls short of providing a value for
each field (ragged right file), the linePosition can end up equal to the
length of the line. This doesn't cause a problem if this is the last
field, but does pose a problem if there are additional fields to be
checked.

On getting the value for the next field the linePosition ends up after
the end of the line and throws an exception. The change makes sure that
the linePosition is either at or below the end of the line length before
trying to start the Substring function. This forces either the NullValue
to be returned, or the exception defined a few lines below to be thrown.
@forcewake forcewake merged commit 20004b3 into forcewake:master Dec 19, 2017
@forcewake
Copy link
Owner

Thank you @heskethw

@amyskippy
Copy link
Contributor Author

No problem! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants