Tab to coma delimited CSV

is there a program available that will convert a tab delimited csv into a coma delimted csv automatically
Who is Participating?
Bill PrewConnect With a Mentor Commented:
Here's a VB script that will do the job.  Save this file as a VBS, let's say cvt.vbs, and then run as either:

cscript cvt.vbs "c:\temp\input.txt" "c:\temp\output.csv"


cscript cvt.vbs "c:\temp\input.txt"

the first will read the first file, make the changes, and write them to the second file.  The second example will read the file, make the changes, and overwrite the same file with the changes.

' Define needed constants
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2

' Get input file name from command line parm, if 2 parms entered
' use second as new output file, else rewrite to input file
If (WScript.Arguments.Count > 0) Then
  sInfile = WScript.Arguments(0)
  WScript.Echo "No filename specified."
End If
If (WScript.Arguments.Count > 1) Then
  sOutfile = WScript.Arguments(1)
  sOutfile = sInfile
End If

' Create file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")

' Read entire input file into a variable and close it
Set oInfile = oFSO.OpenTextFile(sInfile, ForReading, False, TriStateUseDefault)
sData = oInfile.ReadAll
Set oInfile = Nothing

' Replace linefeeds with pipes, trim trailing comma if found
sData = Replace(sData, vbCRLF, ",")
If Right(sData, 1) = "," then sData = Left(sData, Len(sData)-1)

' Write file with any changes made
Set oOutfile = oFSO.OpenTextFile(sOutfile, ForWriting, True)
Set oOutfile = Nothing

' Cleanup and end
Set oFSO = Nothing
MsgBox "Conversion done."

Open in new window

Paul MacDonaldDirector, Information SystemsCommented:
I don't know of one that does it automatically, but Excel will do it manually.  You may be able to script something to semi-automate it.

Open the file and do a find and replace for the tab character for the , character. Excel can do the same with find and replace.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Yeah, download NotePad++ and then do a CTRL+H to find and replace "    " (4 space tab, or however long your tabs are) with ",". 

Then download the current version.
arahmingAuthor Commented:
the program just moved the data around with no comas
Also check that ther is no Null values. This can throw out results
Bill PrewCommented:
Can you provide a sample data file?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.