C#LumenWorks CSV阅读器:标头不存在的字段会抛出错误吗?

时间:2019-05-03 04:36:05

标签: c# csv lumenworks

我正在使用LumenWorks CsvReader处理CSV文件。目前,我正在对CSV文件进行验证,如果字段的标题为空,则需要在其中引发错误。

示例=以下是CSV文件内容

// NOTE: this is pseudo-code only, not executable code!

// start with the min set to the largest float
float min = Float.MAX_VALUE;

// start with the max set to the smallest float
float max = Float.MIN_VALUE;

// start with an average of 0 and count of 0
float average = 0.0;
int count = 0;

// for each value input
{

    // get the value from the user
    float nextValue = getValueFromUser(...);

    // update the min value
    if (nextValue < min) {
        min = nextValue;
    }

    // update the max value
    if (nextValue > max) {
        max = nextValue;
    }

    // recalculate the average
    float sum = average * count;
    count++;
    sum += nextValue;
    average = sum / count;

} // loop until the user is done

// print the min, max and average

此处“测试”是标题不退出的额外字段。但是我观察到CsvReader正在添加一个名为“ Column5”的默认标头字段,而不是引发错误。

这是用于读取和处理CSV文件的代码段。

Header 1,Header 2,Header 3 ,Header 4,Header 5,
Die 11,Die 22,Die 33,Die 44,Die 55,Test
Die 111,Die 222,Die 333,Die 444,Die 555,

我期望如果存在没有标题的字段,则应该引发错误,但是它会添加“ Column5”。有什么方法可以在LumenWorks CSV阅读器中引发错误。

以下是我尝试获取的参考

http://www.nudoq.org/#!/Packages/LumenWorks.Framework.IO/LumenWorks.Framework.IO/CsvReader

谢谢, 阿克沙伊

0 个答案:

没有答案