Hello
I have a txt file generated from barcode machine, where in one column i get vehicle model code with 3 chars and sometime 2 chars and next column vehicle number with 6 chars.
If modelcode has 3 chars there is no problem where i have only one space between 2 column
If modelcode has 2 chars there i am getting 2 spaces between columns and it takes empty records.
Is there any way i can add data if there is 2 spaces.
Attached my sample data and my code
TJW 101555,1
TJW 102009,1
TJW 101335,1
S9 447141,1
S9 447112,1
S9 447175,1
S9 447138,1
S9 447096,1
S9 447105,1
G6 183530,1
G6 183371,1
G6 183372,1
G6 158771,1
G6 183532,1
G6 183531,1
HD 725571,1
TJW 101688,1
TJW 104346,1
TJW 101547,1
Dim dt As New DataTable
dt.Columns.AddRange(New DataColumn(2) {New DataColumn("Model_Code", GetType(String)), New DataColumn("Model_no", GetType(String)), New DataColumn("Model_Name", GetType(String))})
Dim TxtData As String = File.ReadAllText(TxtPAth)
For Each Row As String In txtData.Split(ControlChars.CrLf.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
If Not String.IsNullOrEmpty(Row) Then
dt.Rows.Add()
Dim i As Integer = 0
'For Each cell As String In Row.Split(" "c)
For Each cell As String In Row.Split(" "c) ', StringSplitOptions.RemoveEmptyEntries)
dt.Rows(dt.Rows.Count - 1)(i) = LTrim(RTrim(cell))
i += 1
Next
End If
Next