View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How do I allow blank columns in a .CSV file?

Are you sure you need those additional commas? Lots of programs (excel itself)
won't care when you import it.

But if you actually do need those extra commas, I'd cheat. I'd put a formula
that makes the cell look blank:

=""

It's unique enough to remind me why I did it (when I see it in the formulabar).

And some background saved from a previous post:

This might describe the problem of too many commas in CSV files:

http://support.microsoft.com/default.aspx?scid=77295
Column Delimiters Missing in Spreadsheet Saved as Text

(It actually describes missing delimiter, but if some are "missing", maybe the
ones appearing are "extra".)

(But a lot of programs (excel included) don't care about those extra columns.
Maybe you don't have to care, either???)

Maybe you could write your own exporting program that would behave exactly the
way you want:

Here are some sites that you could steal some code from:

Earl Kiosterud's Text Write program:
www.smokeylake.com/excel
(or directly: http://www.smokeylake.com/excel/text_write_program.htm)

Chip Pearson's:
http://www.cpearson.com/excel/imptext.htm

J.E. McGimpsey's:
http://www.mcgimpsey.com/excel/textfiles.html

RPG7906 wrote:

I have a faily basic excel worksheet that I am saving as a csv file. The file
contains c400 rows and 15 columns. The last 5 columns of data are currently
empty. When I save the file and open it in Notepad to check it is ok, I can
see that only the first 15 rows are being saved correctly and that the rest
are not producing the required 5 commas (to depict the empty columns) as they
should. See below for a paste of the Notepad file. You can see the 5 commas
at the end of records 14 and 15 but not for subsequent rows where there are
no commas:

LOR991587,Fred Bloogs,Male,United Kingdom,Cleveland,LOR
,Fr ed,Engineering
Surveyor,Male,22/05/1957,United Kingdom,,,,,,
LOR991588,Fred, Grogrs,Male,United Kingdom,Essex,LOR
,Fred fred,Project
Director,Male,03/02/1955,United Kingdom,,,,,,
LOR991589,Janice, JolinMale,United Kingdom,Hertfordshire,LOR
m,Janice Joplin,Senior
Quantity Surveyor,Male,18/10/1957,United Kingdom
LOR991590,Julian, Jolpi,Male,United Kingdom,Norfolk,LOR
m,Julian Jolpi,Regional
Commercial Manager,Male,29/08/1958,United Kingdom

I have tried entering data into the last row/last column but this only seems
to correct the 2/3 rows above.

Any help appreciated!


--

Dave Peterson