C # FileHelpers Nulls in tab delimited file

I am parsing a tab delimited file using FileHelpers.

Zero values ​​are ignored after using the attribute FieldNullValue, and I end the error log

cannot be found after the "filed name" field in line 4 (there are fewer fields in the record, the delimiter is invalid, or the next field should be marked as optional).

Separator class definition:

[DelimitedRecord("\t")]

Fields are all rows with the same attributes:

 [FieldTrim(TrimMode.Both)]
 [FieldNullValue("NULL")]
 [FieldQuoted('"', QuoteMode.OptionalForRead, MultilineMode.AllowForRead)]
 public String initials;

Looking at the imported file in a hex editor, I see the back binding (09 09), which I would assume as an empty field.

file line in hex view

As you can see in the screen capture fields 5 and 9, the value is NULL. They are ignored by the filehelper parser. Does anyone know why?

+4
2

:

[FieldTrim(TrimMode.Both)]

, .

+1

, .

-, FileHelpers . [FieldOptional].

-, FieldNullValue("NULL") : null, "NULL". "", null. , :

public class MyEmptyFieldConverter : ConverterBase
{
    protected override bool CustomNullHandling
    {
        /// you need to tell the converter not 
        /// to handle empty values automatically
        get { return true; } 
    }

    public override object StringToField(string from)
    {
        if (String.IsNullOrWhiteSpace(from))
            return "NULL";
        return from;
    }
}

.

[FieldConverter(typeof(MyEmptyFieldConverter))]
public string field9;
+2

All Articles