Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging files dynamically

Status
Not open for further replies.

S1002

Programmer
Aug 28, 2007
14
US
Here is the Code we were using to merge multiple csv files with same format in to one Csv file
How can I make use of this code in ssis or how can I rewrite it to perform the same function.

Thanks for the help in advance.



Dim sFilename As String
Dim PathName As String
Dim PathFinal As String
Dim objFSO As Object
Dim objOutputFile As String

sFilename = "FinalFileName"
PathName= "Path of the file to merge"
PathFinal = "DestinationPath of FinalFileName"

Const ForReading = 1
objFSO = CreateObject("Scripting.FileSystemObject")

objOutputFile = objFSO.CreateTextFile(PathFinal & "\" & sFilename & ".CSV")
strComputer = "."

objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='" & PathName & "'} Where " _
& "ResultClass = CIM_DataFile")

For Each objFile In FileList
objTextFile = objFSO.OpenTextFile(objFile.Name, ForReading)
strText = objTextFile.ReadAll '(The beginning of this line is the line specified by the error)
objTextFile.Close()
objOutputFile.WriteLine(strText)
Next

objOutputFile.Close()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top