Written
May 18, 2017
Here's something that does work, and as an added bonus will only remove commas from numbers. It assumes a well formed CSV and is a bit brute force, but it's short and simple. Save to a VBS file and call it with:
cscript //NoLogo myscript.vbs sourcefile.csv >targetfile.csv
Set objFS=CreateObject("Scripting.FileSystemObject")
strFile = WScript.Arguments.Item(0)
quotechar=""""
Set objFile = objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
insidequote=0
outputline=""
isnumberfield=0
for i=1 to len(strLine)
currentchar = Mid(strLine,i,1)
If currentchar=quotechar then
If insidequote = 1 then
insidequote = 0
Else
insidequote = 1
strNumberCheck=mid(strLine,i+1,InStr(mid(strLine,i+1),quotechar)-1)
isnumberfield=1
for n=1 to len(strNumberCheck)
charNum=Mid(strNumberCheck,n,1)
If (Asc(charNum)<48 or Asc(charNum)>57) and charNum<>"," and charNum<>"." and charNum<>"-" then
isnumberfield=0
End If
next
End If
End If
If currentchar<>"," or insidequote=0 or isnumberfield=0 then
outputline=outputline + currentchar
End If
next
loop