Hello Fellow Tekkies!
I have read a thread resolving this but it does not work for me. I have comma-delimited file with a header and 35 columns.
I need to remove the column 35. How do I do this with vb script?
This is the code I tried:
The result has all data on one line. It is removing the column.
Thanks,
Lloyd
I have read a thread resolving this but it does not work for me. I have comma-delimited file with a header and 35 columns.
I need to remove the column 35. How do I do this with vb script?
This is the code I tried:
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oTextStream = objFSO.OpenTextFile("C:\adp\EPIUWV01.csv")
Set newFile = objFSO.CreateTextFile("C:\adp\EPIUWV01-fixed.csv")
dataArray = Split(oTextStream.ReadAll, vbNewLine)
oTextStream.Close
x = 0
For Each strLine In dataArray
ReDim Preserve clippedArray(x)
clippedArray(x) = Split(strLine,",")
CutColumn = 35
intCount = 0
newLine = ""
For Each Element In clippedArray(x)
If intCount = UBound(clippedArray(x)) Then
EndChar = vbCrLf
Else
EndChar = ","
End If
If intCount <> CutColumn -1 Then
newLine = newLine & Element & EndChar
End If
intCount = intCount + 1
If intCount = UBound(clippedArray(x))+1 Then
newFile.Write newLine
End If
Next
Next
WScript.Echo "Done"
The result has all data on one line. It is removing the column.
Thanks,
Lloyd