I have a tab delimited file. One record contains double quotes.
I'm reading the text TSV file using ADODB and writing the results to MS Access. That double quote is really screwing things up. It appears to end the recordset!
The only answer I see from Google is to read the TSV file using VBA, not ADODB. But this really isn't an answer -- it avoids the problem. I want to use ADODB. It's hard to believe there's no way to read TSV files with a double quote in them. Any ideas?
This is the code that opens the ADODB connection and recordset:
Additionally, I use a schema.init file to force Access to read the file using tab delimiters.Code:Public Sub openADODBConnection() Set c_cn = New ADODB.Connection c_cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=""" & c_crFolder.path & """;" & _ "Extended Properties=""Text;HDR=Yes;FMT=Delimited""" If c_cn.State <> adStateOpen Then Call Me.closeDBConnection(exit_failure, "DB Connection Failed.") Call MsgBox("ADO Connection failed with: " & c_crFolder.path, , "Connection Err") Exit Sub End If End Sub Public Sub openADODBRecordset(table As Tables) Dim file As String, sql As String Set c_rs = New ADODB.Recordset If table = Tables.bulkpor Then file = "FFIEC CDR Call Bulk POR " & Me.dateString & ".txt" ElseIf table = Tables.rc Then file = "FFIEC CDR Call Schedule RC " & Me.dateString & ".txt" End If sql = "SELECT * FROM [" & file & "]" c_rs.Open sql, Me.dbConnection, adOpenForwardOnly, adLockReadOnly, adCmdText If c_rs.State <> adStateOpen Then Call Me.closeDBRecordSet(exit_failure, "Recordset Err") End Sub
Code:[FFIEC CDR Call Schedule RCRII 06302014(1 of 2).txt] Format=TabDelimited
There surely has to be a way to handle this, right? If I had to use a ham-fisted approach, I'd probably pre-process the files to remove the double quotes physically rather than switch to reading the TSV files with a VBA file read/split operation.




Reply With Quote
