vb.net - only read certain columns from a csv -
So I have a CSV file that has extra commas in it. I know that I need anything after a specific column Will not be Then basically no information will be required after the column 12. I do not have a say when CSV is looking for me, so I can not change it there. I was thinking that if you read the first 12 columns and there is a way to ignore the remaining CSV file.
This is a code that looks like now
Thanks for any help
Private subgate data (string as stratified path, Datagid view in the form of a Bierf DG, alternate By-White Nahdar Boolean = Follows as Boolean) start as a string field (100) in the form of string thumb integer = 1, if not, start = 0 if not file is. Example (path) then the end of the return if the dim lines () is in the form of string = file. Readline line (path) rows (0) = rows (0). Chrome (34), "") Fields = Lines (0) .plit (",") If not, then for 1 field for I. 1 field (I) = Str (I) Next closing if dt.Column.Add (New DataColumn (Header.Trim ()) for each header in the form of a string in the dt = New DataTable () field, if desired, In size = 11 while dt.Column.Count & gt; Desired DC Remove the columns. Remove Allow to (the desired size) to start next with I = rows for the next time. Calculation - 1 rows (I) = rows (I). Change (Chr (34), "") field = rows (I). (",") For the slow dray Detrav = dt.Rows.Add () field for j = 0. Calculation - 1 DR (j) = field (j). Next DG.Datasource = DT and Sub
What you really want to do Need is in the loop where you change the field
below , from j = 0 to field. With line - 1
with j = 0 to 11
.
Comments
Post a Comment