Domanda

I am getting an error using Quoted, Tab-Delimited input. The same input with no Quotes works perfectly. Here is a sample input line with '!' denoting a TAB character:

CN!"000012"!"Contents page 1 of 000012"

Here is the error message:

Line: 1 Column: 12. The field itemID is quoted but the quoted char: " not is just before the separator (You can use [FieldTrim] to avoid this error)

I am using the ClassBuilder, and here is the C# output for my generated Class:

[DelimitedRecord("  ")]
public sealed class CN
{

[FieldTrim(TrimMode.Both, " ")]
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.NotAllow)]
public System.String opCode;

[FieldOptional()]
[FieldNullValue(typeof(System.Int32), "0")]
[FieldConverter(typeof(blah.FileHelperClassBuilder+ItemIDConverter))]
[FieldTrim(TrimMode.Both, " ")]
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.NotAllow)]
public System.Int32 itemID;

[FieldOptional()]
[FieldTrim(TrimMode.Both, " ")]
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.NotAllow)]
public System.String itemContents;

[FieldOptional()]
[FieldNullValue(typeof(System.Int32), "0")]
[FieldConverter(typeof(blah.FileHelperClassBuilder+AccountConverter))]
[FieldTrim(TrimMode.Both, " ")]
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.NotAllow)]
public System.Int32? accountID;

[FieldOptional()]
[FieldTrim(TrimMode.Both, " ")]
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.NotAllow)]
public System.String alternateCode;

[FieldOptional()]
[FieldNotInFile()]
[FieldNullValue(typeof(System.Int32), "0")]
[FieldTrim(TrimMode.Both, " ")]
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.NotAllow)]
public System.Int32 sequence;

[FieldOptional()]
[FieldNotInFile()]
[FieldNullValue(typeof(System.Byte), "0")]
[FieldTrim(TrimMode.Both, " ")]
[FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.NotAllow)]
public System.Byte updateItemTime;
}

The DelimitedRecord Attribute indeed has a TAB char in-between the double-quotes.

I am using FileHelpers version 2.9.9.0.

I tried making the Quotes required for all Fields but the first, but no help. It is doing the same thing for several similar Classes. Basically, the error points to the first character after the close-quote for the first Quoted Field, which is a TAB character.

Thanks.

È stato utile?

Soluzione

I solved the problem. I had begun to create my own transient Assembly from the same metadata which I was formerly feeding to the Filehelpers Class Builder (which produced the C# code shown here). However, I was not setting the FieldTrimAttribute TrimChars correctly, and was getting a default set of TrimChars supplied by Filehelpers.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top