Is there a replace function? I would do this:
1. Open file
2. Read each line
3. Split each line into an array using the "," as the split character
4. Recreate each line using the "." character
5. Write each line back to a new file (to preserve the old file)
Something like this:
'----------
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("C:\data.csv") Then
Set objStream = fso.OpenTextFile("C:\data.csv", 1, False, 0)
End If
Set objCopy = fso.CreateTextFile("C:\newdata.csv")
Do While Not objStream.AtEndOfStream
strOldLine = objStream.ReadLine
i = 1
NewArray = Split(strOldLine, ",")
strNewLine = NewArray(0)
Do Until i = UBound(NewArray) + 1
strNewLine = strNewLine & "." & NewArray(i)
i = i + 1
Loop
objCopy.WriteLine strNewLine
Loop
'----------
This is tested code and it works. It will keep any double quotes intact if there are any (there usually are in csv files).
HTH
mmcdonal
|