CsvReader with tab delimiter #2097
Answered
by
JoshClose
gertcloete
asked this question in
Q&A
-
Hi Josh, the Read header does not seem to work on the tab delimeted files? using (var stream = new MemoryStream())
using (var reader = new StreamReader(stream))
using (var writer = new StreamWriter(stream))
using (var csv = new CsvReader(reader, new CsvHelper.Configuration.CsvConfiguration(CultureInfo.InvariantCulture) { Delimiter = "\t", HasHeaderRecord = true }))
{
writer.WriteLine("PrinAcc\tDistAccId\tDistId\tEzypay#\tPrinNo\tLastName\tFirstName\tAmount\tDate\tStatusId\tStatus");
writer.WriteLine("21957\t106811\t2319767\t11059912\t30-06-2010\txxLastNamexx\txxFirstNamexx\t1,138.50\t10/04/2014\t3 \tCleared");
writer.Flush();
stream.Position = 0;
while (true)
{
var hasHeader = csv.ReadHeader();
Assert.True(hasHeader);
//var row = csv.Read();
//if (row == null)
//{
// break;
//}
//row.Dump();
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
JoshClose
Dec 7, 2022
Replies: 2 comments 1 reply
-
@JoshClose ? Any ideas? |
Beta Was this translation helpful? Give feedback.
0 replies
-
You need to call |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
JoshClose
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to call
Read
to read in the first row, then callReadHeader
.ReadHeader
might be better namedParseHeader
or something like that.