I have a csv file of 1.2 million records of text. The alphanumeric fields are wrapped in quotation marks, the date/time or numeric fields are not.
For example \"Fre
I used the following derivative of the code given above to successfully open an arbitrary csv file from VBA in Excel.
Option Explicit
Public cn As Connection
Public Sub DoIt()
Dim strcon As String
Dim strsql As String
Dim rs As RecordsetSet cn = CreateObject("ADODB.Connection")
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\bin\HomePlanet\;" _
& "Extended Properties=""text;HDR=Yes;FMT=Delimited"";"cn.Open strcon
strsql = "SELECT * FROM astuname.csv "
Set rs = New ADODB.Recordset
rs.Open strsql, cn
DoEvents ' pause here to inspect objects and properties rs.Close
End Sub
The rs (recordset) has a collection of fields, with a Count property. Each field as a Type property.
You can reference the fields by sequence number ...
Debug.Print rs.Fields(rs.Fields.Count - 1).Type
Is this sufficient?
If not, post the first several rows of the input file and I'll take it the rest of the way.