Replies: 1 comment
-
This works for me. void Main()
{
var s = new StringBuilder();
s.AppendLine("Id,Name");
s.AppendLine("1,one");
s.AppendLine("2,two");
using (var reader = new StringReader(s.ToString()))
using (var csv = new CsvReader(reader))
{
csv.Read();
csv.ReadHeader();
while (csv.Read())
{
csv.GetRecord<Test>().Dump();
}
}
}
public class Test
{
public int Id { get; set; }
public string Name { get; set; }
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Using version 9.2.3 and trying to read a CSV line by line. According to the docs, this should work:
However, when ReadHeader() is called I get a exception with "Header record has already been read". if I remove the ReadHeader() call, then GetRecord<>() fails with "Fields 'Key' do not exist in the CSV file."
It does exist; the file is created by another task using CsvHelp (and I've checked the file contents).
Thanks,
Jeff
Beta Was this translation helpful? Give feedback.
All reactions