You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is common to have a new line (\n or \r\n) at the end of a text file following the last line (e.g. in Posix as shared on Stack Overflow). Generally this is not seen as the separator for a new CSV record. For the CSV records in my benchmark (https://github.com/joelverhagen/NCsvPerf), all of the parsers I've tested so far have this property of not yielding an empty record at the end.
Repro of what I am talking about:
using System.Text;using Addax.Formats.Tabular;varlines=new[]{"a,b,c","1,2,3","x,y,z"};varfile=string.Join("\r\n", lines)+"\r\n";// line ending at the endvardialect=new TabularDialect("\r\n",',','\"');varstream=new MemoryStream(Encoding.UTF8.GetBytes(file));using(varreader=new TabularReader(stream, dialect)){while(reader.TryPickRecord()){
Console.WriteLine("Record:");while(reader.TryReadField()){
Console.Write(" Field: ");if(reader.TryGetString(outvar value)){
Console.WriteLine(value);}else{
Console.WriteLine("(no value)");}}}}
Actual output:
Record:
Field: a
Field: b
Field: c
Record:
Field: 1
Field: 2
Field: 3
Record:
Field: x
Field: y
Field: z
Record:
Field:
Expected output:
Record:
Field: a
Field: b
Field: c
Record:
Field: 1
Field: 2
Field: 3
Record:
Field: x
Field: y
Field: z
I think this can be easily worked around by detecting a single empty string field on a line when more fields are expected, which is what I will do for my benchmark which will include Addax.
Nice work on the library! Thanks!
The text was updated successfully, but these errors were encountered:
It is common to have a new line (
\n
or\r\n
) at the end of a text file following the last line (e.g. in Posix as shared on Stack Overflow). Generally this is not seen as the separator for a new CSV record. For the CSV records in my benchmark (https://github.com/joelverhagen/NCsvPerf), all of the parsers I've tested so far have this property of not yielding an empty record at the end.Repro of what I am talking about:
Actual output:
Expected output:
I think this can be easily worked around by detecting a single empty string field on a line when more fields are expected, which is what I will do for my benchmark which will include Addax.
Nice work on the library! Thanks!
The text was updated successfully, but these errors were encountered: