LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-08-2010, 08:37 PM   #1
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
How to add quotes between words in a cvs file?


Hello linux fans

I exported a spreadsheet file into cvs format.

The cvs file is formatted this way

field1,field2,field3,..etc

I want it to be in a Quote delimited format like so

"field1","field2","field3",..etc

I goggled online but could not get the right answer.

If you know please post.

Thanks in advance
 
Old 03-08-2010, 10:16 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
CSV (Comma-Separated Variables)

In the example you show, the double-quotes are not delimiters----a delimiter is a character that separates fields. You would not--for example-- be able to manipulate fields by specifying " as the delimiter.

Regardless, try this to install the quotes per your example:

Code:
sed 's/\([^,]*\)/\"\1\"/g' filename > newfilename
If you really want the " to be the delimiter, then:

Code:
sed 's/,/\"/g' filename > newfilename
 
Old 03-08-2010, 10:34 PM   #3
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Original Poster
Rep: Reputation: 57
Hey pixellany,

Thanks for the code. It worked like a charm.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cvs merge a file not done in CVS Four Programming 1 06-13-2008 02:09 PM
Using single quotes vs double quotes in PHP strings vharishankar Programming 6 07-11-2005 11:41 AM
add your fun quotes and stuff Mattentaart General 16 05-05-2004 04:24 PM
how to add some quotes to fortune? Vincent Slackware 2 02-25-2004 09:13 AM
How to add a new project in CVS? Claus Programming 1 10-16-2003 05:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration