csvdecoder.cs
来自「csv解析类」· CS 代码 · 共 39 行
CS
39 行
using System;
using System.Collections.Generic;
using System.Text;
namespace QiHe.CodeLib.Csv
{
public class CsvDecoder
{
public static CsvData Decode(string text)
{
return Decode(text, false);
}
public static CsvData Decode(string text, bool hasHeader)
{
if (text == null)
{
throw new ArgumentNullException("text");
}
bool success;
Parser parser = new Parser();
CsvData csvData = parser.ParseCsvData(new TextInput(text), out success);
if (success)
{
if (hasHeader)
{
csvData.Header = csvData.Records[0];
csvData.Records.RemoveAt(0);
}
return csvData;
}
else
{
throw new Exception("There are syntax errors in the csv text.");
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?