CSVファイルを読み取るための非常に優れたライブラリであるFileHelpersを見つけましたが、奇妙な問題があります。助けていただければ幸いです。前もって感謝します !
マッピング後、右側の最後の列から常に1文字が削除されます。
FileHelpers.dllバージョン2.0.0を使用しています-DotNet2.0FileHelpers_2_0_0_bin_docs_wizard.zip
たとえば、私はこのようなCSVを持っています(一部の列は引用されていますが、一部は引用されていません。変更される可能性があります)
name;surname
"John";Smith
"Jack";Baker
そして、ファイルを読んだ後:
FileHelperEngine<SemicolonsRow> engine = new FileHelperEngine<SemicolonsRow>();
engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue;
res = engine.ReadFile("C:\\a.txt");
if (engine.ErrorManager.ErrorCount > 0)
engine.ErrorManager.SaveErrors("C:\\Log.txt");
私はこれを手に入れます:
res[0].Col0 with name
res[0].Col1 with surnam (lack of e at the end)
res[1].Col0 with John
res[1].Col0 with Smit (lack of h at the end)
私がこのようにファイルを読んだとき:
name;surname;country
"John";Smith;USA
"Jack";Baker;Canada
問題は3番目の列にあるので、次のようになります。countr US Canad
私のFileHelpersクラス:
[IgnoreEmptyLines()]
[DelimitedRecord(";")]
public sealed class SemicolonsRow
{
[FieldOptional()]
[FieldQuoted('"', QuoteMode.OptionalForRead, MultilineMode.AllowForRead)]
public String Col0;
[FieldOptional()]
[FieldQuoted('"', QuoteMode.OptionalForRead, MultilineMode.AllowForRead)]
public String Col1;
[FieldOptional()]
[FieldQuoted('"', QuoteMode.OptionalForRead, MultilineMode.AllowForRead)]
public String Col2;
[FieldOptional()]
[FieldQuoted('"', QuoteMode.OptionalForRead, MultilineMode.AllowForRead)]
public String Col3;
}
何か案は ?