LibCSV.CSVReader.Next C# (CSharp) Method

Next() public method

Reads and parses next record.
public Next ( ) : bool
return bool
        public bool Next()
        {
            Reset();

            var line = ReadLine();
            if (string.IsNullOrEmpty(line) || line.Trim().Length < 1)
            {
                return false;
            }

            var length = line.Length;
            if (line != new string(_dialect.Delimiter, length))
            {
                for (var i = 0; i < length; i++)
                {
                    if (IsNull(line[i]))
                    {
                        throw new BadFormatException("Line contains NULL byte!");
                    }

                    ProcessChar(line[i]);
                }

                SaveField();
            }

            _index++;
            return true;
        }

Usage Example

Beispiel #1
0
 public void Next_EmptyLine_NextReturnsFalse()
 {
     string input = "Header#1;Header#2;Header#3\r\n1;2;3\r\n \r\n";
     using (var dialect = new Dialect(true, ';', '"', '\0', false, "\r\n", QuoteStyle.QuoteMinimal, false, true))
     {
         using (var reader = new CSVReader(dialect, new StringReader(input)))
         {
             Assert.IsTrue(reader.Next());
             Assert.IsFalse(reader.Next());
         }
     }
 }
All Usage Examples Of LibCSV.CSVReader::Next