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

Support Padding via a Converted in the library #149

Open
iremmats opened this issue Aug 11, 2015 · 6 comments · May be fixed by #373
Open

Support Padding via a Converted in the library #149

iremmats opened this issue Aug 11, 2015 · 6 comments · May be fixed by #373

Comments

@iremmats
Copy link

Support padding without having to write your own converter.
http://stackoverflow.com/questions/22015002/filehelpers-mixing-delimited-and-fixed-length-records

@MarcosMeli
Copy link
Owner

Hi @iremmats

Padding is already supported, but not well documented 👎

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
}

@MarcosMeli
Copy link
Owner

After hit comment I understand that is for a DelimitedRecord 😢

Is implemented for FixedLengthRecord classes, so is a feature to consider

@iremmats
Copy link
Author

My use cases has been with fixed field records so far.
But yeah, it would be a nice feature for Delimited Records too.

@MarcosMeli MarcosMeli changed the title Support Padding Support Padding via a Converted in the library Aug 11, 2015
@MarcosMeli
Copy link
Owner

We must add a

 PaddingConverter(totalLength, paddingChar)

or something like

@iremmats
Copy link
Author

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.

@MarcosMeli
Copy link
Owner

You are right

[PaddingConverter(totalLength, alignMode, paddingChar)

@mcavigelli mcavigelli modified the milestone: 3.2 Sep 24, 2017
telljimmy pushed a commit to telljimmy/FileHelpers that referenced this issue Aug 15, 2018
telljimmy pushed a commit to telljimmy/FileHelpers that referenced this issue Aug 15, 2018
…mbiguous. Explicitly declared arguments instead of argument array

MarcosMeli#149
@mcavigelli mcavigelli self-assigned this Aug 21, 2018
@mcavigelli mcavigelli removed their assignment Jan 7, 2019
@jeremykdev jeremykdev linked a pull request Nov 8, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants