Fix some end-of-file simple TSV parsing
This commit is contained in:
parent
4148475031
commit
203458fdf7
@ -1033,15 +1033,22 @@ public class SaneTsv
|
|||||||
|
|
||||||
fields.Add(fieldBytes.ToArray());
|
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");
|
throw new Exception("Found 0 fields on last line. Possibly because of extra \\n after last record");
|
||||||
}
|
}
|
||||||
if (numFields != fields.Count)
|
if (numFields != fields.Count)
|
||||||
|
{
|
||||||
|
if (endIndex == inputBuffer.Length)
|
||||||
{
|
{
|
||||||
throw new Exception($"Expected {numFields} fields on line {line}, but found {fields.Count}");
|
throw new Exception($"Expected {numFields} fields on line {line}, but found {fields.Count}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
return records.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var fieldStrings = new string[fields.Count];
|
var fieldStrings = new string[fields.Count];
|
||||||
for (int j = 0; j < fields.Count; j++)
|
for (int j = 0; j < fields.Count; j++)
|
||||||
|
Loading…
Reference in New Issue
Block a user