View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dirk Van de moortel Dirk Van de moortel is offline
external usenet poster
 
Posts: 7
Default CSV file, but not regular commas


"Dirk Van de moortel" wrote in message
...

"Vikxcel" wrote in message
...

Hi everyone,
Got a problem.
I have 100 text files that i combine into 1 csv file. Text files are
single quote separated and comma seperated, it looks like this

'105139.002','3','PANEL LAYOUT & WIRING','

This is fine, as soon as it becomes a CSV file i remove all the single
quotes and it's all good. But i get a problem when i encounter a
regular comma inside the text, like this:

'105139.002','3','PANEL LAYOUT, WIRING','


As soon as it becomes a text file, do not remove the
single quotes, but replace them with double quotes.
Excel will then nicely read the thing in.


Forgot to mention...
This only works if your data does no contain any double
quotes by itself. To avoid having a problem with that,
first double all double quotes in the file before you replace
the single quotes with doubles.
Example:
'105139.002','3','PANEL "LAYOUT", WIRING'
==
'105139.002','3','PANEL ""LAYOUT"", WIRING'
==
"105139.002","3","PANEL ""LAYOUT"", WIRING"

When you open this, save the result as CSV again, and
look at it with a text editor, you will see:
105139.002,3,"PANEL ""LAYOUT"", WIRING"
Only the fields that contain a comma, will retain the
delimiting double quotes.

Dirk Vdm


Cheers,
Dirk Vdm