Tab to coma delimited CSV

Posted on 2011-02-22
Medium Priority
Last Modified: 2012-05-11
is there a program available that will convert a tab delimited csv into a coma delimted csv automatically
Question by:arahming
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 34

Expert Comment

by:Paul MacDonald
ID: 34953258
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.
LVL 14

Expert Comment

ID: 34953286

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.

Expert Comment

ID: 34953522
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.
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

LVL 56

Accepted Solution

Bill Prew earned 2000 total points
ID: 34953780
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


Author Comment

ID: 34954804
the program just moved the data around with no comas

Expert Comment

ID: 34956798
Also check that ther is no Null values. This can throw out results
LVL 56

Expert Comment

by:Bill Prew
ID: 34957463
Can you provide a sample data file?


Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question