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

COMP-3 field is being read with a value 3 less than expected value #639

Open
anavimr opened this issue Aug 21, 2023 · 3 comments
Open

COMP-3 field is being read with a value 3 less than expected value #639

anavimr opened this issue Aug 21, 2023 · 3 comments
Labels
question Further information is requested

Comments

@anavimr
Copy link

anavimr commented Aug 21, 2023

Trying to read a file which has the following
07 IM-LKUP-LM-HH-MM-SS PIC S9(7) COMP-3.

The resulting value for each record is coming up with a value thats 3 more than expected.
For instance instead of seeing 131444 - its resulting in 131441
Happens for every single record - all other fields are being parsed correctly - this is the only COMP field.

Added the following option
.option("debug", "hex")
and I see
{131441, 0131441F}
Here is what I see in the file using a hex editor: (ignore double quotes)
"��à�"

Any idea why this is happening and how to fix it.

Is this because of an unsigned COMP field and the sign value should be ignored but the code is somehow including it in the value?

@anavimr anavimr added the question Further information is requested label Aug 21, 2023
@yruslan
Copy link
Collaborator

yruslan commented Aug 22, 2023

0131441F is COMP-3 encoded 131441. Looks correct . Why do you expect 131444?

@anavimr
Copy link
Author

anavimr commented Aug 22, 2023

I think we figured out the issue. The file record format is U (undefined)
Does Cobrix support this.
The first field(s9999 Comp-3) defines how many bytes the record is….

@yruslan
Copy link
Collaborator

yruslan commented Aug 23, 2023

Yes, you can use record length expressions, like:

.option("record_format", "F")
.option("record_length_field", "RECORD_LENGTH_FIELD + 10")

more details are in README

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

No branches or pull requests

2 participants