View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Excel CSV Files; Creating Of

"Bob" wrote:
I have created a small Excel file that I wish to be saved as a CSV.
Question: do I have to put " marks around the beginning, and end,
of the text in each cell, or does Excel automatically do what is
required for CSV when I tell it to Save As a CSV ?


Excel puts double-quotes around text where Excel deems it is necessary.
Generally, that is text that contains the CSV separator (usually comma) and
text that contains double-quotes. However, there might be other situations.


"Bob" wrote:
I did not put any " marks around any text, and when I opened it
up in Notepad++, there were a single set of double quotes
(e.g., "Bob") marks around the text.


That is odd. Excel does not double-quote simple text like Bob when I try
it, even if the cell is formatted as Text.


"Bob" wrote:
Is the initial Excel file I created without any " text marks
a "true" CSV ? Or,...?


Yes, as long as columnar data is separated using commas (or the List
Separator configured in the Regional and Language Options control panel).


"Bob" wrote:
Working with, and creating, a CSV seems a bit confusing, at least to me.
I did read many of the CSV articles via a Google, but still not too clear.


Understandably so.

Creating (saving to) CSV files should not be confusing. But getting Excel
to interpret (read) CSV files as you intended might be tricky.

In particular, even if you surround text with double-quotes, Excel still
might not interpret the data as text. For example, "000123" is interpreted
as a number and the cell is formatted as General. So the leading zeros will
not appear in Excel by default, despite the double-quotes in the CSV file.

Sometimes, we must import the CSV file instead of opening it directly using
Excel. By "import", I mean: use the Get External Data / From Text
operation. That allows us to specify a column of data to be formatted as
Text (or Date), not General.

However, even that might not be sufficient if the data to be treated as text
is not columnar, and Excel insists on interpreting it as numeric.

Other applications might interpret (read) the CSV file differently, always
treating the double-quoted data as text.

There are no standards for reading a CSV file. Only for writing it (RFC
4180).