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

Variable length fields in a fixed length record #377

Open
dhananjay77 opened this issue Dec 17, 2020 · 0 comments
Open

Variable length fields in a fixed length record #377

dhananjay77 opened this issue Dec 17, 2020 · 0 comments

Comments

@dhananjay77
Copy link

dhananjay77 commented Dec 17, 2020

I have a below requirement :

I have a fixed length file with variable length price.

public class PriceRecord
{
FieldFixedLength(8)]
public string Person;
[FieldFixedLength(3)]
public string Price;
[FieldFixedLength(20)]
public string Address;
}
Price is not receiving as fixed length, we get price as : 4 length or 5 length characters e.g. 1000, 10000 or 118.3 or 18.3
Any record more than 3 characters is an error record. however, I wanted to import it as valid record, I mean I want field level variable length.

var engine = new FixedFileEngine();

        engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue;
        engine.AfterReadRecord += AfterReadRecord;

        PriceRecord[] result = engine.ReadFile(@"D:\\PriceRecord.txt");

foreach (var detail in result1)
{
Console.writeline( " Customer: {0}, ",detail.Customer);
}
In this 4 or 5 length recordlines are treated as error line.

Thanks,

@dhananjay77 dhananjay77 changed the title Variable length records Variable length fields in a fixed length record Dec 17, 2020
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

No branches or pull requests

1 participant