본문 바로가기

기타툴

디비버(dbeaver) csv 파일 큰따옴표 붙여서 가져오기 데이터 import

728x90

디비버(dbeaver) csv 파일 큰따옴표 붙여서 가져오기 데이터 import


 

Error 코드 ORA-01843 : 지정한 월이 부적합합니다.

 

 

 

CSV 파일 만들었는데 디비버에서 데이터를 제대로 가져오지 못하는 문제가 생겼다. 기존 테이블 데이터를 csv로 내려받았을 때 컬럼 데이터가 큰따옴표(")로 감싸진 것을 보고 데이터를 import 할 때에 큰따옴표를 넣어서 해결했다.

 

1. 엑셀 csv 파일에 큰따옴표 추가해서 저장하는 방법

Alt + F11 키를 눌러서 모듈 추가하고 아래 문장을 입력한 뒤 F5 버튼을 눌러서 실행한다.

Sub CSVFile()
'updateby Extendoffice
    Dim xRg As Range
    Dim xRow As Range
    Dim xCell As Range
    Dim xStr As String
    Dim xSep As String
    Dim xTxt As String
    Dim xName As Variant
    On Error Resume Next
    If ActiveWindow.RangeSelection.Count > 1 Then
      xTxt = ActiveWindow.RangeSelection.AddressLocal
    Else
      xTxt = ActiveSheet.UsedRange.AddressLocal
    End If
    Set xRg = Application.InputBox("Please select the data range:", "Kutools for Excel", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    xName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")
    xSep = Application.International(xlListSeparator)
    Open xName For Output As #1
    For Each xRow In xRg.Rows
        xStr = ""
        For Each xCell In xRow.Cells
            xStr = xStr & """" & xCell.Value & """" & xSep
        Next
        While Right(xStr, 1) = xSep
            xStr = Left(xStr, Len(xStr) - 1)
        Wend
        Print #1, xStr
    Next
    Close #1
    If Err = 0 Then MsgBox "The file has saved to: " & xName, vbInformation, "Kutools for Excel"
End Sub

 

출처 : https://ko.extendoffice.com/documents/excel/3620-excel-save-worksheet-data-as-csv-file-with-without-double-quotes.html#a1