Home > Software design >  Filehelpers fixed size records can it ignore a single extra space/line-ending in some files?
Filehelpers fixed size records can it ignore a single extra space/line-ending in some files?

Time:10-30

Using FileHelpers FixedFileEngine to read in large files from customers. One customer seems to have an extra whitespace per record (perhaps lf/cf TBD).

BUT can I support this difference easily in the parsing record definition?

[FixedLengthRecord()]
public class ClaimEntryDch
{
  ...
  [IgnoreOptionalWhitespace(1)] // something like this?
  string IgnoreThis { get; set; }
}

CodePudding user response:

Perhaps you're looking for the [FieldOptional] attribute?

[FixedLengthRecord()]
public class ClaimEntryDch
{
    ...
    [FieldFixedLength(1)]
    [FieldOptional]
    string IgnoreThis { get; set; }
}

See this example fiddle for a demonstration.

CodePudding user response:

Answering my own Xerillo's answer pointed the way by creating an exception that gave me the eventual answer using FixedMode.AllowLessChars.

[FixedLengthRecord(FixedMode.AllowLessChars)]
public class ClaimEntryCenter
  • Related