Exemple #1
0
 public void Append(string item)
 {
     builder.Append(currentSeparator);
     if (item == null)
     {
         item = "";
     }
     builder.Append(CSVUtilities.BuildCSVItem(item));
     currentSeparator = separatorCharacter.ToString();
 }
        public static List <Record> ParseRecordsFromReader
        (
            System.IO.TextReader reader,
            string entrySeparators = DefaultSeparators,
            IEnumerable <string> commentPrefixes = null
        )
        {
            commentPrefixes = commentPrefixes ?? DefaultCommentPrefixes;
            var records = new List <Record>();

            while (reader.Peek() != -1)
            {
                var nextRow = CSVUtilities.ReadNextCSVRow(reader, entrySeparators)
                              .Select(item => item.Trim());
                if (nextRow.Any() && !LineIsCommentedOut(nextRow.First(), commentPrefixes))
                {
                    records.Add(new Record(nextRow));
                }
            }
            return(records);
        }