示例#1
0
        public void AddLine(CSVLine line)
        {
            if (line.FieldsCount != m_nbFields)
            {
                throw new ArgumentException(String.Format("line fields count {0} does not match with table fields count {1}", line.FieldsCount, m_nbFields));
            }

            m_Lines.Add(line);
        }
示例#2
0
        public CSVTable ParseToTable(string[] lines, int nbFields)
        {
            CSVTable table = new CSVTable(nbFields);

            List <string[]> parsedRawLines = Parse(lines);

            foreach (string[] l in parsedRawLines)
            {
                CSVLine newTableLine = new CSVLine(l.Length);
                for (int iField = 0; iField < newTableLine.FieldsCount; iField++)
                {
                    newTableLine[iField] = new CSVField(l[iField]);
                }

                table.AddLine(newTableLine);
            }

            return(table);
        }