vb.net - Change function to read tab delimited file into datable? -
i need change below function read tab delimited file ideas how this?
public function convertcsvtodatatable(byval columnnames boolean) datatable try dim dt new datatable each columnname in getcolumns(columnnames) dt.columns.add(columnname) next dim filereader new streamreader(filename) if columnnames filereader.readline() end if dim line string = filereader.readline while not isnothing(line) line = line.replace(chr(34), "") dt.rows.add(line.split(",")) line = filereader.readline end while filereader.close() return dt catch ex exception 'log file end try return nothing end function
i replace following line:
dt.rows.add(line.split(","))
with:
dt.rows.add(line.split(vbtab))
that should split on tab delimited values...
that said, recommend specialized library this, since scv / tsv can complicated. kbcsv.
Comments
Post a Comment