Home All Groups Group Topic Archive Search About

Text File Manipulation

Author
30 Sep 2006 10:53 PM
Garth Wells
I need to open up a .csv and replace all adjacent commas
(,,) with comma zero comma (,0,). Anybody have an
example of how to do this?

Thanks

Author
1 Oct 2006 2:18 AM
Stephany Young
3 steps:
  Read the entire content of the file into string
  Replace all occurrences of ",," with ",0,"
  Write the string to a new file or overwite the existing file

Check out the documentation for the StreamReader class.  You will find a
range of examples, combinations of which will help you out.


Show quoteHide quote
"Garth Wells" <nob***@nowhere.com> wrote in message
news:bACTg.3620$DU3.1968@tornado.texas.rr.com...
>I need to open up a .csv and replace all adjacent commas
> (,,) with comma zero comma (,0,). Anybody have an
> example of how to do this?
>
> Thanks
>
Author
1 Oct 2006 3:32 AM
Terry Olsen
MyString=MyString.Replace(",,",",0,")

Show quoteHide quote
"Garth Wells" <nob***@nowhere.com> wrote in message
news:bACTg.3620$DU3.1968@tornado.texas.rr.com...
>I need to open up a .csv and replace all adjacent commas
> (,,) with comma zero comma (,0,). Anybody have an
> example of how to do this?
>
> Thanks
>
Author
1 Oct 2006 12:18 PM
Herfried K. Wagner [MVP]
"Garth Wells" <nob***@nowhere.com> schrieb:
>I need to open up a .csv and replace all adjacent commas
> (,,) with comma zero comma (,0,). Anybody have an
> example of how to do this?


'System.IO.StreamReader', 'System.IO.StreamWriter', 'String.Replace',
'Strings.Replace'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
1 Oct 2006 5:52 PM
Spam Catcher
"Garth Wells" <nob***@nowhere.com> wrote in news:bACTg.3620$DU3.1968
@tornado.texas.rr.com:

> I need to open up a .csv and replace all adjacent commas
> (,,) with comma zero comma (,0,). Anybody have an
> example of how to do this?

If you're doing it on a per line basis, I would open the file using
System.IO and reach each line. Then use String.Replace to replace all
adjacent commas.

Once the line is fixed, use StringBuilder to re-concatentate all the lines
together (don't use string concatenation (i.e. String A + String B) if you
have more than 10 - 20 lines, string concatenation slows down exponentially
- it gets REALLY slow for large files).
Author
1 Oct 2006 9:10 PM
Izzy
No VB.NET required for this.

Open the file with Notepad
Click Edit, Click Replace
In the "Find What" box type in ",,"
In the "Replace With" box type in ",0,"
Click Replace All
Save Document
You're done!

If this operation has to be done over and over again, then use VB.NET
as others have described.


Garth Wells wrote:
Show quoteHide quote
> I need to open up a .csv and replace all adjacent commas
> (,,) with comma zero comma (,0,). Anybody have an
> example of how to do this?
>
> Thanks
Author
1 Oct 2006 11:16 PM
Terry Olsen
Touche'

Show quoteHide quote
"Izzy" <israel.rich***@gmail.com> wrote in message
news:1159737029.780520.189350@h48g2000cwc.googlegroups.com...
> No VB.NET required for this.
>
> Open the file with Notepad
> Click Edit, Click Replace
> In the "Find What" box type in ",,"
> In the "Replace With" box type in ",0,"
> Click Replace All
> Save Document
> You're done!
>
> If this operation has to be done over and over again, then use VB.NET
> as others have described.
>
>
> Garth Wells wrote:
>> I need to open up a .csv and replace all adjacent commas
>> (,,) with comma zero comma (,0,). Anybody have an
>> example of how to do this?
>>
>> Thanks
>