Solved

Tab to coma delimited CSV

Posted on 2011-02-22
7
1,128 Views
Last Modified: 2012-05-11
is there a program available that will convert a tab delimited csv into a coma delimted csv automatically
0
Comment
Question by:arahming
7 Comments
 
LVL 33

Expert Comment

by:paulmacd
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.
0
 
LVL 14

Expert Comment

by:athomsfere
ID: 34953286
Notepad?

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.
0
 
LVL 9

Expert Comment

by:rawinnlnx9
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 ",".

http://notepad-plus-plus.org/download

Then download the current version.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 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"

or

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)
Else
  WScript.Echo "No filename specified."
  WScript.Quit
End If
If (WScript.Arguments.Count > 1) Then
  sOutfile = WScript.Arguments(1)
Else
  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
oInfile.Close
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)
oOutfile.Write(sData)
oOutfile.Close
Set oOutfile = Nothing

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

Open in new window

~bp
0
 
LVL 1

Author Comment

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

Expert Comment

by:runtimecomputer
ID: 34956798
Also check that ther is no Null values. This can throw out results
0
 
LVL 51

Expert Comment

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

~bp
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now