Replies: 5 comments
-
There must be something else going on. Can you make a failing example? This works: void Main()
{
var s = new StringBuilder();
s.AppendLine("Id,Name");
s.AppendLine("1,one ");
using (var reader = new StringReader(s.ToString()))
using (var csv = new CsvReader(reader))
{
csv.Configuration.TrimOptions = TrimOptions.None;
var records = csv.GetRecords<Test>().ToList();
$"'{records[0].Name}'".Dump();
}
}
public class Test
{
public int Id { get; set; }
public string Name { get; set; }
} |
Beta Was this translation helpful? Give feedback.
-
Hi, I have the same issue. it trims end:
var s = new StringBuilder();
s.AppendLine("Id;Name");
s.AppendLine("1;\" one \"");
using (var r = new StringReader(s.ToString()))
using (var csv = new CsvReader(r))
{
csv.Configuration.TrimOptions = TrimOptions.None;
csv.Configuration.IgnoreQuotes = false;
csv.Configuration.Delimiter = ";";
var records = csv.GetRecords<Test>().ToList();
//$"'{records[0].Name}'".Dump();
Assert.Equal(" one ", records[0].Name); // fails
} instead of " one " I got " one" I did not have that issue with
remark : downgrading to 9.2.2, the behaviour is ok |
Beta Was this translation helpful? Give feedback.
-
Can you try the latest? (12.1.1) |
Beta Was this translation helpful? Give feedback.
-
Hi Josh, there appears to be a problem with trimming values in quotes with leading spaces. Such as " one" will trim to " one" instead of "one" like it should. We updated from 9.1.0 to 12.1.x and noticed this issue. |
Beta Was this translation helpful? Give feedback.
-
Can you please provide a failing unit test? I haven't seen the behavior people are talking about yet. This works fine for me in the version 12.2.1. void Main()
{
var s = new StringBuilder();
s.AppendLine("Id,Name");
s.AppendLine("1,\" one \"");
using (var reader = new StringReader(s.ToString()))
using (var csv = new CsvReader(reader))
{
csv.Configuration.TrimOptions = TrimOptions.InsideQuotes;
csv.Read();
csv.ReadHeader();
csv.Read();
$"'{csv.GetField(1)}'".Dump();
}
} |
Beta Was this translation helpful? Give feedback.
-
I have a dotnet core 2 code
with the following configuration:
and this string gets trimmed:
See here:
Please am I doing something wrong? I need not to trim the fields. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions