gpt4 book ai didi

c# - FileHelpers:读取文件时如何处理引用的字段

转载 作者:行者123 更新时间:2023-11-30 19:05:02 25 4
gpt4 key购买 nike

这是我要读取的数据:

"Adam C. Emality","1Z620Y1V034826","14.40"
"Ethel Baeron","1Z620Y1V034604","15.19"
"Donna Lidt","1Z620Y1V034650","12.37"

然后在读入数据后,我想对两个集合执行 Join,一个是数组,一个是列表——我的代码如下。然而,在执行读取文件行后,我的字符串存储如下 "\"Adam C. Emality\"" "\"1Z620Y1V034826\"" "\"14.40\""...等等。为什么会这样?我不想包含 ",我不知道为什么要添加 \

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FileHelpers;
using Parser;

namespace Amazon_File
{
class SpreadSheet
{
public void create(IEnumerable<SpreadList> list)
{


var steamengine = new FileHelperEngine<Records>();
var records = steamengine.ReadFile(@"C:\Users\Danny\Documents\Visual Studio 2013\Projects\Amazon File\Amazon File\Daniel.csv");

var spreadlist = from x in list
join y in records on x.Name equals y.Name
select new { y.Name, y.Track, y.worldPrice, x.ItemPrice, x.Quantity };



[DelimitedRecord(",")]
public class Records
{

public string Name;

public string Track;

public string worldPrice;
}

public class SpreadList
{
public string Name { get; set; }
public string Title { get; set; }
public string ItemPrice { get; set; }
public string Quantity { get; set; }
}
}

最佳答案

您必须添加 [FieldQuoted] 以使库自动删除它们 http://www.filehelpers.net/docs/html/T_FileHelpers_FieldQuotedAttribute.htm

[DelimitedRecord(",")]
public class Records
{
[FieldQuoted]
public string Name;

[FieldQuoted]
public string Track;

[FieldQuoted]
public string worldPrice;
}

关于c# - FileHelpers:读取文件时如何处理引用的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32105732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com