View Single Post
  #8   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


"Vikxcel" wrote in message
...

Thank you all for your help. I can't believe how busy this forum is, 12
hours and I'm on page 13?!?! WOW.

Can anyone help me with making a .bat file to find & replace?
I know how to find, but what about find and replace? is it
complicated?

Thanks ahead to everyone!
Viktor.


You can use (for instance) the unix utility sed.
Download it from (for instance again)
http://short.stop.home.att.net/freesoft/txtutil4.htm
sed414b.zip and sed414d.zip
Copy sed.exe to a place in the path.
Try to read the pdf-file sed.pdf.
Forget about the other files.
I think this version will only work with simple 8.3 filenames:

Create a bat-file csvquote.bat to call sed twice:
the first call to replace the " with "", and the second
to replace ' with ".
The essence is:
sed -e s/\"/\"\"/g %infile% temp.tmp
sed -e s/\'/\"/g temp.tmp %outfile%

Here's an example of a bat-file:

@echo off
if not "%1" == "" goto okay1
echo CSVQuote.bat - Usage: csvquote infile [outfile]
goto exit
:okay1
set infile=%1
if exist %infile% goto okay2
echo Infile %infile% not found!
got exit
:okay2
set outfile=%2
set tempfile=csvtemp.tmp
if "%outfile%" == "" set outfile=%infile%

sed -e s/\"/\"\"/g %infile% %tempfile%
sed -e s/\'/\"/g %tempfile% %outfile%
del %tempfile%
:exit

Dirk Vdm