Splitting Text files

William Park opengeometry at NOSPAM.yahoo.ca
Tue Jul 2 18:15:21 EDT 2002


Ken Seergobin <kseergobin at sympatico.ca> wrote:
> Thanks.  Csplit makes the task much easier!  The extraction of the
> critical data lines plus relevant fields was never an issue.  With your
> suggestions though I can now write batch or shell scripts to do most of
> the work.  However, python offers unlimited possibilities when
> analysing/visualizing the data.  As such, I was looking for an easy way
> to abandon the use of mulitple unix(like) tools.

"Right tool for the right job" is the key insight (as Guido would say :-)

> 
> Part of what I was looking for was the ability to use the root of the
> bitmap name as the output name.  I can extract the bitmap name, but don't
> know how to redirect data to a file with a similar name (e.g.,
> bitmap1.txt).

In shell,
    out=`egrep 'bitmap[0-9]\.txt' `
    command ... > $out

In Python,
    out = "..."
    f = open(out, 'w')
    f.write(...)

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin



More information about the Python-list mailing list