Support Padding via a Converted in the library
Support padding without having to write your own converter. http://stackoverflow.com/questions/22015002/filehelpers-mixing-delimited-and-fixed-length-records
Hi @iremmats
Padding is already supported, but not well documented :-1:
You must use FieldAlign, http://www.filehelpers.net/docs/html/T_FileHelpers_FieldAlignAttribute.htm
Can you translate the answer to stackoverflow ? thanks !!
[DelimitedRecord("|")]
public class Customer
{
public int CustId; //variable length
public string Name; //variable length
public decimal Balance; //variable length
[FieldConverter(ConverterKind.Date, "dd-MM-yyyy")]
public DateTime AddedDate;
[FieldAlign(AlignMode.Right, '0')]
public int Code; // this one must have 10 characters with "zero-fill", like
// 153 must look like 0000000153
}
After hit comment I understand that is for a DelimitedRecord :cry:
Is implemented for FixedLengthRecord classes, so is a feature to consider
My use cases has been with fixed field records so far. But yeah, it would be a nice feature for Delimited Records too.
We must add a
PaddingConverter(totalLength, paddingChar)
or something like
Make sure it support both left and right padding plus there is no problem with int/string/decimal conversions. Most cases its numbers that needs zeros using left padding.
You are right
[PaddingConverter(totalLength, alignMode, paddingChar)