forcewake / FlatFile

FlatFile is a library to work with flat files
MIT License
106 stars 39 forks source link

Allow gaps with [FixedLengthField] #41

Open valentynpopov opened 8 years ago

valentynpopov commented 8 years ago

I am parsing using IFlatFileMultiEngine and [FixedLengthField] attributes.

There is a number of fields I don't care about. I thought I could just define the fields I need, simply skipping the irrelevant ones, like this:

[FixedLengthField(1, 10)]
  public string ClientId { get; set; }

[FixedLengthField(100, 50)]
  public string Address { get; set; }

I'd expect the 'gap '(data in positions 11..99) to be ignored. However, it looks like the 'index' parameter isn't used in the this case, and Address would start from 11 rather than 100.

mniak commented 6 years ago

I understand that index indicates the field order rather than representing the starting position on the line. Try creating a gap field just to skip data, like in the example below:

[FixedLengthField(1, 10)]
  public string ClientId { get; set; }

[FixedLengthField(2, 90)]
  public string Gap01 { get; set; }

[FixedLengthField(3, 50)]
  public string Address { get; set; }
ejsmith commented 6 years ago

It seems really silly to have to map this to a dummy property when you really just want to ignore the data. One of the claimed benefits of this library is speed, but you are forcing us to process and allocate data that we don't care about.

kfrancis commented 6 years ago

This part is particularity odd. Having to include gaps for parsing is really really weird. Please fix, (pretty please) 👍