在我的餐厅,我有以下定义:
enum gic_rpt_columns{AGYDIV, STS, GICID, LASTNAME,IRSTNAME, CudeAGE, DESCRIPTION , PREMIUM, RUNDATE, BILMO, EMPLOYERPERCENT };
public class csv_parser
{
.
.
.
private string[] m_column_headings;
List<string[]> m_csv_array = new List<string[]>();
.
.
.
下面的法典将添加一栏标题,然后在卷宗中添加行文。
using (TextFieldParser parser = new TextFieldParser(m_csv_path))
{
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
if (!parser.EndOfData)
{
m_column_headings = parser.ReadFields();
m_csv_array.Add(m_column_headings);
}
while (!parser.EndOfData)
{
string[] fields = parser.ReadFields();
m_csv_array.Add(fields);
m_row_count++;
}
}