2
如何使用ssis將一組xls文件轉換爲製表符分隔的文件?如何使用ssis轉換一組xls 2製表符分隔的文件?
有一個腳本在谷歌search.Please這樣sugest我如何實現這一目標使用SSIS
Dim objFSO, objFile, objFileTSV
Dim strLine, strNewLine, strNewText
Dim FileNameLength, LineLength, NewFileName, Linepos, Quote, QuoteCount, TotalFilesConverted
objFSO = CreateObject("scripting.filesystemobject")
strCurPath = objFSO.GetAbsolutePathName(".")
TotalFilesConverted = 0
For Each objFile In objFSO.getfolder(strCurPath).Files
If UCase(Right(objFile.Name, 4)) = ".CSV" Then
FileNameLength = Len(objFile.Name) - 4
NewFileName = Left(objFile.Name, FileNameLength) & ".tsv"
objFile = objFSO.OpenTextFile(objFile, 1)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
LineLength = Len(strLine)
Linepos = 1
strNewLine = ""
Quote = False
QuoteCount = 0
Do While Linepos <= LineLength
If Mid(strLine, Linepos, 1) = "," And Not Quote Then
strNewLine = strNewLine + vbTab
Quote = False
ElseIf Mid(strLine, Linepos, 1) = Chr(34) Then
QuoteCount = QuoteCount + 1
If QuoteCount = 2 And Linepos <> LineLength Then
If Mid(strLine, Linepos, 2) = Chr(34) & Chr(34) Then
strNewLine = strNewLine + Chr(34)
Linepos = Linepos + 1
Quote = True
QuoteCount = 1
Else
Quote = False
QuoteCount = 0
End If
Else
Quote = True
End If
Else
strNewLine = strNewLine + Mid(strLine, Linepos, 1)
End If
Linepos = Linepos + 1
Loop
strNewText = strNewText & strNewLine & vbCrLf
Loop
objFile.Close()
objFileTSV = objFSO.CreateTextFile(NewFileName)
objFileTSV.WriteLine(strNewText)
TotalFilesConverted = TotalFilesConverted + 1
strNewText = ""
objFileTSV.Close()
End If
Next
MsgBox(CStr(TotalFilesConverted) + " Files Converted from CSV to TSV.")
據瞭解,這可以在腳本中使用task..but讓我有一些線索
你爲什麼要在SSIS中使用vb6?它支持.Net – brian
該腳本對此問題的相關性如何?它所做的只是將CSV文件轉換爲TSV文件。 –
這是一種瘋狂的做事方式,您應該使用SSIS任務來獲取單個xls文件,將感興趣的列拉出並輸出到不同的文件中。然後,如果您有一批文件需要以這種方式進行處理,則內部操作可以通過各種方式轉換爲循環。使用腳本最有可能會變得更慢,儘管當文件大小開始變大時這可能只是一個問題。 – meataxe