View previous topic :: View next topic |
Author |
Message |
Capinha Newbie
Joined: 19 Oct 2006 Posts: 13 Location: Portugal
|
Posted: Tue Mar 25, 2008 10:08 pm Post subject: Replacing white spaces with newlines |
|
|
Hello there,
I have several large sized number matrix with columns separated by whitespace, and I'm trying to transform the whitespace in a carriage return, so that all values converge in one column.
Something like:
from this:
123 122 133 122
122 111 111 222
...
to this:
123
122
133
122
122
111
111
222
...
I've tried to use this expression using string.dll extension
%b = @string(RegxRepInFile,c:\file.txt,c:\output.txtt," ",@cr(),)
and also:
%b = @string(RegxRepInFile,c:\file.txt,c:\output.txtt," ",(\r),)
but the first returns a rectangular symbol in place of the whitespace and the other just inserts the "r" character...
The optional use of repeat or if sentences instead revealed to be very very time consuming...
any sugestions?
Cheers
César _________________ César Capinha |
|
Back to top |
|
|
ShinobiSoft Professional Member
Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Wed Mar 26, 2008 4:04 am Post subject: |
|
|
Try this::
Code: |
REM The following code assumes that string list #1 contains the contents
REM of the file to transform the data for. I am also assuming that we
REM are replacing @chr(32)<space> with a line feed @chr(13)@chr(10)
%%text = @text(1)
repeat
%p = @pos(" ",%%text)
if @greater(%p,0)
%%text = @strdel(%%text,%p)
%%text = @strins(%%text,%p,@chr(13)@chr(10))
end
until @zero(%p)
REM Now put the modified file contents into string list #1
list assign,1,%%text
|
_________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|