tonyflora63
MIS
Hi does anyone know how to deleted columns in a csv file?
Thanks in advance.
Thanks in advance.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'==========================================================================
'
' NAME: RemoveColumnFromCSV.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE :
' COPYRIGHT (c) 2007 All Rights Reserved
'
' COMMENT:
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'
' IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS
' BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
' DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
' WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
' ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
' OF THIS CODE OR INFORMATION.
'
'==========================================================================
'On Error Resume Next
Dim objFSO, dataArray, clippedArray()
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Create an array out of the CSV
'open the data file
Set oTextStream = objFSO.OpenTextFile("C:\Testcsv.csv")
Set newFile = objFSO.CreateTextFile("C:\newCSV.txt")
'make an array from the data file
dataArray = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
x = 0
For Each strLine In dataArray
'Now make an array from each line
ReDim Preserve clippedArray(x)
clippedArray(x) = Split(strLine,",")
CutColumn = 3
intCount = 0
newLine = ""
For Each Element In clippedArray(x)
If intCount = UBound(clippedArray(x)) Then
EndChar = vbCrLf
Else
EndChar = ","
End If
If intCount <> CutColumn 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"
'On Error Resume Next
Dim objFSO, dataArray, clippedArray()
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Create an array out of the CSV
'open the data file
Set oTextStream = objFSO.OpenTextFile("C:\staging\test.csv")
Set newFile = objFSO.CreateTextFile("C:\staging\newCSV.csv")
'make an array from the data file
dataArray = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
x = 0
For Each strLine In dataArray
'Now make an array from each line
ReDim Preserve clippedArray(x)
clippedArray(x) = Split(strLine,",")
CutColumn = 53
CutColumn = 52
CutColumn = 51
CutColumn = 50
CutColumn = 49
CutColumn = 48
CutColumn = 47
CutColumn = 45
CutColumn = 44
CutColumn = 43
CutColumn = 42
CutColumn = 41
CutColumn = 40
CutColumn = 39
CutColumn = 37
CutColumn = 36
CutColumn = 35
CutColumn = 34
CutColumn = 33
CutColumn = 32
CutColumn = 31
CutColumn = 30
CutColumn = 29
CutColumn = 28
CutColumn = 27
CutColumn = 26
CutColumn = 25
CutColumn = 24
CutColumn = 23
CutColumn = 22
CutColumn = 18
CutColumn = 17
CutColumn = 16
CutColumn = 14
CutColumn = 13
CutColumn = 12
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"
Where did this come from? As far as I know it isn't true.Also, jet databases are not supported on 64bit systems.