Dear All,
I am into trouble while reading .csv file having spaces.
I am reading csv file with below code;
SAMPLE INPUT FILE:
AAAA,43438894322,USA,BASIC
BBBB,73738 9393 939,INDIA,BASIC
CCCC,00293993020,UK,PREMIUM
all is well until i get any file with data having space like
01 0002 020929
65650002 543
The place where its 01 0002 020929 it is returning NULL where as there is data available. Same if its alphanumeric like OXFORD UNIVERSITY it returns correct, but in case of numbers it returns NULL.
Any help will be appreciated,
Best Regards,
Sam
I am into trouble while reading .csv file having spaces.
I am reading csv file with below code;
SAMPLE INPUT FILE:
AAAA,43438894322,USA,BASIC
BBBB,73738 9393 939,INDIA,BASIC
CCCC,00293993020,UK,PREMIUM
all is well until i get any file with data having space like
01 0002 020929
65650002 543
Code:
Dim connCSV As New ADODB.Connection
Dim rsCSV As New ADODB.Recordset
connCSV.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& Path & ";Extended Properties='text;HDR=" & hasHeader & ";FMT=Delimited'"
rsCSV.Open "Select * From " & fileName, _
connCSV, adOpenStatic, adLockReadOnly, adCmdText
Do While Not rsCSV.EOF()
cntRows = cntRows + 1
With MSFlexGrid1
currRow = .Rows - 1
.TextMatrix(currRow, 1) = IIf(IsNull(rsCSV.Fields(0).Value), "", rsCSV.Fields(0).Value)
.TextMatrix(currRow, 2) = rsCSV.Fields(1).Value
.TextMatrix(currRow, 3) = Format(rsCSV.Fields(2).Value, "####.000")
.TextMatrix(currRow, 4) = PadRight(Left(rsCSV.Fields(3).Value, 8), "XXXXXXXX")
.TextMatrix(currRow, 5) = IIf(IsNull(rsCSV.Fields(4).Value), "", rsCSV.Fields(4).Value)
.TextMatrix(currRow, 6) = rsCSV.Fields(5).Value
.TextMatrix(currRow, 7) = rsCSV.Fields(6).Value
.Rows = .Rows + 1
End With
rsCSV.MoveNext
Loop
The place where its 01 0002 020929 it is returning NULL where as there is data available. Same if its alphanumeric like OXFORD UNIVERSITY it returns correct, but in case of numbers it returns NULL.
Any help will be appreciated,
Best Regards,
Sam