• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Re: Remove extra Double codes from CSV Files (vb Script Language)


Pegasus [MVP]

Strange - my initial reply appears to have disappeared into the never-never.
I'll try to post it once more:

You could do it like this for every line of text:
1. Replace every "," with your own delimiter. I use chr(0).
2. Remove all remaining double quotes.
3. Replace your own delimiters with ",".
4. Surround the line with double quotes.
This code appears to work for your data sample:

Q = """"
Z = Chr(0)
sDelimiter = Q & "," & Q
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile("d:\test.txt")
While Not oFile.AtEndOfStream
sLine = Replace(oFile.ReadLine, sDelimiter, Z)
sLine = Replace(sLine, Q, "")
sLine = Q & Replace(sLine, Z, sDelimiter) & Q
WScript.Echo sLine

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)