Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CSV file, but not regular commas


Hi everyone,
Got a problem.
I have 100 text files that i combine into 1 csv file. Text files ar
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 singl
quotes and it's all good. But i get a problem when i encounter
regular comma inside the text, like this:

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

Notice after Layout there is a comma, but I don't want that to be in
separate cell.
So I'm trying to figure out something along the lines of this logic.
Look in cell D1
if last character is ' then skip to next one
if last character is not, then name that cell A
Go to the right one cell
if that cell has a ' at the end, then call it a B, and combine A
B
if that cell does not have a ' then name it b and go to next cell t
the right
then i need to delete all the left overs after i combine.
Please help me with coding.
Thanks,
Viktor

--
Vikxce
-----------------------------------------------------------------------
Vikxcel's Profile: http://www.excelforum.com/member.php...fo&userid=1860
View this thread: http://www.excelforum.com/showthread.php?threadid=49564

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default CSV file, but not regular commas

don't use the comma as the delimiter, use the '.

--


Gary


"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','

Notice after Layout there is a comma, but I don't want that to be in a
separate cell.
So I'm trying to figure out something along the lines of this logic.
Look in cell D1
if last character is ' then skip to next one
if last character is not, then name that cell A
Go to the right one cell
if that cell has a ' at the end, then call it a B, and combine A &
B
if that cell does not have a ' then name it b and go to next cell to
the right
then i need to delete all the left overs after i combine.
Please help me with coding.
Thanks,
Viktor.


--
Vikxcel
------------------------------------------------------------------------
Vikxcel's Profile:
http://www.excelforum.com/member.php...o&userid=18607
View this thread: http://www.excelforum.com/showthread...hreadid=495646



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CSV file, but not regular commas


Hello Viktor,

You can use the Replace function in VBA to change the comma between the
single quotes to another charater. You could use either a Tab or Pipe
"|" as a delimiter. Excel will accept either in flat file (CSV).

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=495646

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default CSV file, but not regular commas


"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.

Cheers,
Dirk Vdm


  #5   Report Post  
Posted to microsoft.public.excel.programming
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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CSV file, but not regular commas


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.


--
Vikxcel
------------------------------------------------------------------------
Vikxcel's Profile: http://www.excelforum.com/member.php...o&userid=18607
View this thread: http://www.excelforum.com/showthread...hreadid=495646

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CSV file, but not regular commas


can I use VBA to find/replace text string in a set of batch files?


--
Vikxcel
------------------------------------------------------------------------
Vikxcel's Profile: http://www.excelforum.com/member.php...o&userid=18607
View this thread: http://www.excelforum.com/showthread...hreadid=495646

  #8   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert email address file in Excel 2000 to Word file with commas Mike A. Excel Discussion (Misc queries) 8 October 14th 08 02:48 PM
File Convert With commas to txt format jayceejay Excel Discussion (Misc queries) 3 December 14th 06 07:06 PM
Convert Regular Excel file into csv file crazymfr Excel Discussion (Misc queries) 1 November 16th 06 02:16 PM
How to remove commas from a downloaded .dat file? arvind Excel Worksheet Functions 3 September 5th 06 01:09 PM
When converting an .xls file to .csv I get too many commas at the. One-eyed-Ian Excel Discussion (Misc queries) 3 December 7th 04 12:03 AM


All times are GMT +1. The time now is 01:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"