Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving XLS as CSV with Quotes

Status
Not open for further replies.

DataChick

IS-IT--Management
Apr 17, 2002
108
US
I need to save my Excel document as a CSV file with the quotations. Just selecting the CSV format without quotation marks around the data doesn't put the quotes around the data when you open it in another application (ex. Word or Notepad)...but if I manually put quotations around each data piece and then save as CSV, when I open it in another application it shows three quotes (""") around each data piece.

Any suggestions?

Thank you in advance.

"The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents."
-Nathaniel Borenstein
 
CSV files only need quotes around things that could mess up the parsing. Generally, this means that any column that contains ',' or '"' will get quoted and/or escaped, and everything else is unchanged.

So isn't won't be quoted, but one, two will become "one, two". And she said "that's stupid" will become "she said ""that's stupid""".

Make sense?

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
The issue is that I need to have the data in a particular format - which normally wouldn't require the quotes around it based on your explanation - but it's for an application that requires the quotes to be around the data (not Microsoft).

I'm able to get the data to export correctly from an Access database but the users have requested to eliminate the Access step and be able to create the upload file (with the specific formatting) directly from Excel.

"The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents."
-Nathaniel Borenstein
 
Thanks for the explanation Steve - I never really worked out the logic before.

DataChick: maybe you could open the csv file in notepad or word and then use Edit,Replace eg

replace , with ","
replace paragraph mark with "paragraph mark"
manualy put a quote at the start and end of the file

save it


Gavin
 
Not that easy, I'm afraid. Excel has already escaped and quoted the things that need quoting. If you do a global edit, you'll screw it up...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top