Trimming Text file 
Author Message
 Trimming Text file

ok, i am working in pb dos 3.5 and i want to trim a text file from spaces
before the text: e.g.

------------
    Here is my story... blah blah

         and here is some more
and some more

 nope, still more

-------------

Ok, so i want to turn that, into this:

--------------
Here is my story... blah blah

and here is some more
and some more

nope, still more
--------------

i have tryed making my own code but it is too buggy and does not work
and is very LARGE could someone please give my some  code in the simplist
form

THANX LOADS

Pete

P.S. SORRY FOR CROSSPOSTING!



Wed, 01 May 2002 03:00:00 GMT  
 Trimming Text file

Quote:

> ok, i am working in pb dos 3.5 and i want to trim a text file from spaces
> before the text:
[snip]
> i have tryed making my own code but it is too buggy and does not work
> and is very LARGE could someone please give my some  code in the simplist
> form

Look up the following functions;
LINE INPUT #
LTRIM$

You may also find RTRIM$, EXTRACT$ and REMOVE$ helpful.

I have not used Power BASIC for a while but I really appreciate
the rich set of string handling functions.

One problem you may be encountering is a variation in "plain" text
files between DOS, Mac and UNIX platforms.  If this is the case
you should run eg. tr, sed or AWK on the file while on the UNIX
platform (or using DJGPP for DOS).  For the Mac there is MacGAWK
or otherwise perhaps MacPerl or MacPython (but those are like
using a sledgehammer to crack a nut in these circumstances).
If you get a "String too long" error (15) you should suspect this.

   Bernard

--
Bernard P. Murray, PhD
bpmurray at cgl . ucsf . edu
Department of Cellular & Molecular Pharmacology, UCSF



Wed, 01 May 2002 03:00:00 GMT  
 Trimming Text file

Quote:
> ok, i am working in pb dos 3.5 and i want to trim a text file from spaces
> before the text: e.g.

> ------------
>     Here is my story... blah blah
> -------------

> Ok, so i want to turn that, into this:

> --------------
> Here is my story... blah blah
> --------------

> i have tryed making my own code but it is too buggy and does not work
> and is very LARGE could someone please give my some  code in the simplist

Is this a trick question? Assuming not, try something like:

        OPEN "file1.txt" FOR INPUT AS #1
        OPEN "file2.txt" FOR OUTPUT AS #2
        DO UNTIL EOF(1)
                LINE INPUT #1, a$
                PRINT #2, LTRIM$(a$)
        LOOP
        CLOSE



Thu, 02 May 2002 03:00:00 GMT  
 Trimming Text file
Thats it!!

Thats what i wanted, Thanx


Quote:

> > ok, i am working in pb dos 3.5 and i want to trim a text file from
spaces
> > before the text: e.g.

> > ------------
> >     Here is my story... blah blah
> > -------------

> > Ok, so i want to turn that, into this:

> > --------------
> > Here is my story... blah blah
> > --------------

> > i have tryed making my own code but it is too buggy and does not work
> > and is very LARGE could someone please give my some  code in the
simplist

> Is this a trick question? Assuming not, try something like:

> OPEN "file1.txt" FOR INPUT AS #1
> OPEN "file2.txt" FOR OUTPUT AS #2
> DO UNTIL EOF(1)
> LINE INPUT #1, a$
> PRINT #2, LTRIM$(a$)
> LOOP
> CLOSE



Thu, 02 May 2002 03:00:00 GMT  
 Trimming Text file

shell
sed "s/^ +//" infile > outfile
exit

or shell" .. "
but you have to use chr$, twice.

----------------------------------------
http://oak.oakland.edu/simtel.net/msdos/
----------------------------------------

                txtutl/
SED15      62082  910930  unix-compatible streaming editor v1.5 tc src
SED15x     20300  910930  unix-compatible streaming editor v1.5 exe/docs

----------------------------------------
       ftp://garbo.uwasa.fi/pc
----------------------------------------

        unix/
SED15       hhsed stream editor sources, e.raymond+d.kirschbaum+h.helman
SED15x      hhsed executable, e.raymond+d.kirschbaum+h.helman
===========================================================================

n.b.
to download any file of the above
you may have to convert its  NAME  to   lowercase

--
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, ex seders moderator                                   sed u soon
               it is not zat we do not see the  s o l u t i o n          
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+



Fri, 03 May 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. File Conversion: UNIX.txt to DOS.txt and trim trailing blanks

2. Deleting text in text file

3. Email text body from text file?

4. How do I read lines of Text from Text File and add them to Array

5. Write 2D Text Array in a text file

6. Inserting a string of text into a text file

7. parsing a long text file for specific text

8. text file and text box script

9. inserting text into a text file

10. Import a text file into a C5 .TPS file

11. Exporting Clarion DAT file to ASCII(Text)File

12. C4-print topspeed file to a text file

 

 
Powered by phpBB® Forum Software