How do I read row 0 when there are no headers?
I've got a bunch of CSVs with no header rows.
When I do
var dt = DataTable.New.ReadCsv("source-file.csv");
foreach (var row in dt.Rows)
{
var idAsString = row.Values[0];
}
the first row is skipped. What's the best way to avoid skipping the first row if I know the CSV has no headers?
Thanks
I haven't tried this but I am assuming that have you tried .... dt.GetRow(0) ???
DataTable needs headers from somewhere. There are overloads of DataTable.New that let you pass in the headers. If you truly don't care about the names, you can pass in placeholder names ("c1", "c2", "c3"), but you should at least get the column count correct.
@MikeStall , unfortunately DataTable doesn't have overload of DataTable.New with columns and delimiter specified both. Could you please add such?