Sql loader - second enclosure string not present

前端 未结 4 2186
终归单人心
终归单人心 2021-01-07 02:12

I am loading a .csv file data into oracle table through sql loader. One of the fields has a new line character (CRLF) in its data and so, am getting the below error:

4条回答
  •  青春惊慌失措
    2021-01-07 02:24

    I found the best way to load the .csv files with fields containing newline and comma.Please run the macro over the .csv file and then load using sqlloader

    Sub remove()
    Dim row As Integer
    
    Dim oxcel As Excel.Application
    Dim wbk As Excel.Workbook
    Set oxcel = New Excel.Application
    Set wbk = oxcel.Workbooks.Open("filename.csv", 0, True)
    row = 0
    With oxcel
    .ActiveSheet.Select
     Do
     row = row + 1
        'Assume first column is PK and so checking for empty pk to find the number of rows
      Loop Until IsEmpty(Cells(row, 1)) Or IsNull(Cells(row, 1))
      Range(Cells(1, 24), Cells(row - 1, 24)).Select
      For Each oneCell In Selection
      oneCell.Value = Application.Substitute(Application.Substitute 
     (Application.Substitute  (CStr(oneCell.Value), vbLf, vbCr), vbCr, "-"),",","-")
    
        Next oneCell
    
        End With
         End Sub
    

    It's running perfect for me.

提交回复
热议问题