Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding double quote delimiters into csv file

I have a number of text files which contain radio programme titles where each item is on a separate line, e.g.:

15 by 15 15 Minute Drama Adrian Mole Afternoon Drama Afternoon Reading etc 

I would like to add double quotes as delimiters to each line, e.g.:

"15 by 15" "15 Minute Drama" "Adrian Mole" "Afternoon Drama" "Afternoon Reading" etc 

I thought I might be able to do this in Excel but not been able to find a way. I really don't mind whether the solution is Excel based or something else, as long as I don't have to do it manually.

Can anyone help please?

like image 839
user338034 Avatar asked Aug 11 '14 07:08

user338034


People also ask

Are double quotes allowed in CSV?

Yes. You can import double quotation marks using CSV files and import maps by escaping the double quotation marks. To escape the double quotation marks, enclose them within another double quotation mark.

Can CSV files have quotes?

You can put quotes, dashes and spaces in the CSV file. Fields that contain a special character (comma, newline, or double quote), must be enclosed in double quotes. If a field's value contains a double quote character it is escaped by placing another double quote character next to it.

Can we change delimiter in CSV file?

Click Data > Get External Data > From Text to select a file and open the Text Import Wizard. Click Next button to continue. Select one or more delimiters that fits your data. You can see if the data is separated correctly in the Data preview section.


1 Answers

Here's a way to do it without formulas or macros:

  1. Save your CSV as Excel
  2. Select any cells that might have commas
  3. Open to the Format menu and click on Cells
  4. Pick the Custom format
  5. Enter this => \"@\"
  6. Click OK
  7. Save the file as CSV

(from http://www.lenashore.com/2012/04/how-to-add-quotes-to-your-cells-in-excel-automatically/)

like image 197
Anthony Wang Avatar answered Sep 24 '22 07:09

Anthony Wang