Fix some end-of-file simple TSV parsing
This commit is contained in:
parent
7230f982ac
commit
b56236cbb7
@ -1033,13 +1033,20 @@ public class SaneTsv
|
||||
|
||||
fields.Add(fieldBytes.ToArray());
|
||||
|
||||
if (fields.Count == 0)
|
||||
if (fields.Count == 0 && endIndex == inputBuffer.Length)
|
||||
{
|
||||
throw new Exception("Found 0 fields on last line. Possibly because of extra \\n after last record");
|
||||
}
|
||||
if (numFields != fields.Count)
|
||||
{
|
||||
throw new Exception($"Expected {numFields} fields on line {line}, but found {fields.Count}");
|
||||
if (endIndex == inputBuffer.Length)
|
||||
{
|
||||
throw new Exception($"Expected {numFields} fields on line {line}, but found {fields.Count}");
|
||||
}
|
||||
else
|
||||
{
|
||||
return records.ToArray();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user