' Text file I/O constants
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
'Create the file system object for creating folders:
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Define folders and files to work with
strScriptDir = objFSO.GetAbsolutePathName(".")
strBaseDir = "B:\EE\EE28634944"
strFileIn = strBaseDir & "\file.csv"
strLogFile = strScriptDir & "\log-file-split.txt"
' Open log file for appending
Set objLog = objFSO.OpenTextFile(strLogFile, ForAppending, True)
' Make sure input folder exists
If Not objFSO.FolderExists(strBaseDir) Then
objLog.WriteLine Now & " ERROR: Input folder """ & strBaseDir & """ does not exist."
Wscript.Quit
End If
' Make sure input file exists
If Not objFSO.FileExists(strFileIn) Then
objLog.WriteLine Now & " ERROR: Input file """ & strFileIn & """ does not exist."
Wscript.Quit
End If
' Read entire input file into an array
Set objFileIn = objFSO.OpenTextFile(strFileIn, ForReading, False, TriStateUseDefault)
arrLines = Split(objFileIn.ReadAll, VbCrLf)
objFileIn.Close
Set objFileIn = Nothing
' Process all lines from input file
For i = LBound(arrLines) To UBound(arrLines)
' Skip blank lines in input file
If arrLines(i) <> "" Then
' Skip header line
If i > LBound(arrLines) Then
' Process data line
arrFields = Split(arrLines(i), ";")
If UBound(arrFields) = 2 Then
' Write to individual file for just this ORG
WriteOrgFile arrFields
Else
' WARNING (not 3 fields in data line)
objLog.WriteLine Now & " WARNING: Processing line """ & i+1 & """, found """ & UBound(arrFields)+1 & """ fields, must be 3."
End If
End If
End If
Next
' Wrap up
objFileOut.Close
objLog.Close
' Subroutine to add a row to the individual file for the ORG
Sub WriteOrgFile(arrFields())
' Build name for this ORG file from data in ORG field (node2.node3)
strFileOrg = strBaseDir & "\" & arrFields(0) & ".csv"
' If the file doesn't exist yet we need the header line
If objFSO.FileExists(strFileOrg) Then
blnNeedHeader = False
Else
blnNeedHeader = True
End If
' Open this file for apending
Set objFileOrg = objFSO.OpenTextFile(strFileOrg, ForAppending, True)
' Write header line of needed
If blnNeedHeader Then
objFileOrg.WriteLine strHeader
End If
' Write data line
objFileOrg.WriteLine Join(arrFields, ";")
End Sub
~bp
' Text file I/O constants
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
'Create the file system object for creating folders:
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Define folders and files to work with
strScriptDir = objFSO.GetAbsolutePathName(".")
strBaseDir = "C:\Users\SESA249410\Desktop\Scripts-revised\test\folder\spot-mstt-match-multiple-generationa"
strFileIn = strBaseDir & "\test.csv"
strLogFile = strScriptDir & "\log-file-split.txt"
' Open log file for appending
Set objLog = objFSO.OpenTextFile(strLogFile, ForAppending, True)
' Make sure input folder exists
If Not objFSO.FolderExists(strBaseDir) Then
objLog.WriteLine Now & " ERROR: Input folder """ & strBaseDir & """ does not exist."
Wscript.Quit
End If
' Make sure input file exists
If Not objFSO.FileExists(strFileIn) Then
objLog.WriteLine Now & " ERROR: Input file """ & strFileIn & """ does not exist."
Wscript.Quit
End If
' Read entire input file into an array
Set objFileIn = objFSO.OpenTextFile(strFileIn, ForReading, False, TriStateUseDefault)
arrLines = Split(objFileIn.ReadAll, VbCrLf)
objFileIn.Close
Set objFileIn = Nothing
' Process all lines from input file
For i = LBound(arrLines) To UBound(arrLines)
' Skip blank lines in input file
If arrLines(i) <> "" Then
' Skip header line
If i > LBound(arrLines) Then
' Process data line
arrFields = Split(arrLines(i), ";")
If UBound(arrFields) = 2 Then
' Write to individual file for just this ORG
WriteOrgFile arrFields
Else
' WARNING (not 3 fields in data line)
objLog.WriteLine Now & " WARNING: Processing line """ & i+1 & """, found """ & UBound(arrFields)+1 & """ fields, must be 3."
End If
End If
End If
Next
' Wrap up
objFileOut.Close
objLog.Close
' Subroutine to add a row to the individual file for the ORG
Sub WriteOrgFile(arrFields())
' Build name for this ORG file from data in ORG field (node2.node3)
strFileOrg = strBaseDir & "\" & arrFields(0) & ".csv"
' If the file doesn't exist yet we need the header line
If objFSO.FileExists(strFileOrg) Then
blnNeedHeader = False
Else
blnNeedHeader = True
End If
' Open this file for apending
Set objFileOrg = objFSO.OpenTextFile(strFileOrg, ForAppending, True)
' Write header line of needed
If blnNeedHeader Then
objFileOrg.WriteLine strHeader
End If
' Write data line
objFileOrg.WriteLine Join(arrFields, ";")
End Sub
If UBound(arrFields) = 2 Then
' Write to individual file for just this ORG
WriteOrgFile arrFields
Else
' WARNING (not 3 fields in data line)
objLog.WriteLine Now & " WARNING: Processing line """ & i+1 & """, found """ & UBound(arrFields)+1 & """ fields, must be 3."
' Text file I/O constants
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
'Create the file system object for creating folders:
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Define folders and files to work with
strScriptDir = objFSO.GetAbsolutePathName(".")
strBaseDir = "C:\Users\SESA249410\Desktop\Scripts-revised\test\folder\spot-mstt-match-multiple-generationa"
strFileIn = strBaseDir & "\test.csv"
strLogFile = strScriptDir & "\log-file-split.txt"
' Open log file for appending
Set objLog = objFSO.OpenTextFile(strLogFile, ForAppending, True)
' Make sure input folder exists
If Not objFSO.FolderExists(strBaseDir) Then
objLog.WriteLine Now & " ERROR: Input folder """ & strBaseDir & """ does not exist."
Wscript.Quit
End If
' Make sure input file exists
If Not objFSO.FileExists(strFileIn) Then
objLog.WriteLine Now & " ERROR: Input file """ & strFileIn & """ does not exist."
Wscript.Quit
End If
' Read entire input file into an array
Set objFileIn = objFSO.OpenTextFile(strFileIn, ForReading, False, TriStateUseDefault)
arrLines = Split(objFileIn.ReadAll, VbCrLf)
objFileIn.Close
Set objFileIn = Nothing
' Process all lines from input file
For i = LBound(arrLines) To UBound(arrLines)
' Skip blank lines in input file
If arrLines(i) <> "" Then
' Skip header line
If i > LBound(arrLines) Then
' Process data line
arrFields = Split(arrLines(i), ";")
' Write to individual file for just this ORG
WriteOrgFile arrFields
End If
End If
Next
' Wrap up
objLog.Close
' Subroutine to add a row to the individual file for the ORG
Sub WriteOrgFile(arrFields())
' Build name for this ORG file from data in ORG field (node2.node3)
strFileOrg = strBaseDir & "\" & arrFields(0) & ".csv"
' If the file doesn't exist yet we need the header line
If objFSO.FileExists(strFileOrg) Then
blnNeedHeader = False
Else
blnNeedHeader = True
End If
' Open this file for apending
Set objFileOrg = objFSO.OpenTextFile(strFileOrg, ForAppending, True)
' Write header line of needed
If blnNeedHeader Then
objFileOrg.WriteLine strHeader
End If
' Write data line
objFileOrg.WriteLine Join(arrFields, ";")
End Sub
~bp
Tinder.porter.tata.toto.te
Tinder.porter.tirter.toto.
Tinder.porter.tata.toto.te
or
Tinder.porter.tirter.toto.
Tinder.porter.tata.toto.te
Tinder.porter.tata.toto.te
Sinder.porter.tirter.toto.
Sinder.porter.tata.toto.te
Sinder.porter.tata.toto.te
~bp