Re: Remove spaces in CSV file using VB6
- From: erewhon@xxxxxxxxxx (J French)
- Date: Thu, 06 Apr 2006 08:48:38 GMT
On Wed, 5 Apr 2006 11:21:47 +0100, "Mike Williams"
<Mike@xxxxxxxxxxxxxxxxx> wrote:
<snip>
Actually that's the way I would do it Jerry. Certainly a lot faster than
multiple use of the Replace function, and it certainly isn't worth bothering
using a Byte array instead of a string unless speed is critical (which I
don't think it really is in the OP's case). The only snag is the the code as
above will remove each entire group of spaces where there is more than one
in succession but will leave single spaces untouched, which I don't think he
wanted. However, to remove all "extra" spaces (leaving a single space at
each location) you just need to make the following slight modification, by
changing:
<snip>
I am pretty sure that the OP wants to keep the single space between
BOD and 5
2006-01-28 08:57:28.887000000,TNS,NINF,BOD 5 ,250,2006-01-29
To be honest I would probably process this line by line and field by
field using a buffer to read and another to write.
At some stage the OP is going to need to do Field specific
modifications, which would mean a total re-write, or at best a line by
line post/pre-pass
Also the current method has zilch ability to detect bad data
- and, as with production systems, detecting problems gets
exponentially more 'expensive' the further it gets down the line.
However, my impression was that he wanted a 'quick fix' so I decided
not to give him a lecture <g>
I've a feeling that it would be a lot faster on a Byte Array as one
would shuffle the Bytes down inplace, then do a ReDim Preserve which
does not move the data if one is resizing down
Hmm... one could do the same with StrPtr and MoveMemory on the raw
string ...
.
- References:
- Re: Remove spaces in CSV file using VB6
- From: J French
- Re: Remove spaces in CSV file using VB6
- From: Mike Williams
- Re: Remove spaces in CSV file using VB6
- Prev by Date: Re: Floating Point bug
- Next by Date: Re: Checkbox/pressed button: First click only sets focus
- Previous by thread: Re: Remove spaces in CSV file using VB6
- Next by thread: vb6 listview
- Index(es):
Relevant Pages
|