Phil Lawrence on 22 Jan 2004 14:03:40 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: seek with (<>) ?


Jeff Abrahamson wrote:

I think you're being too clever by far!

If you're calling it stdin, behave like it's stdin,
> which is not rewindable...

and Mark Dominus wrote:

> ...standard input might be attached to a pipe, and
> once you've read the data from the pipe, it's gone.

Ohhhh. I didn't know the pipe wasn't rewindable. I guess that about covers it! :-) (And explains why my pseudo-code made no sense to Mark, who certainly did know that pipes aren't rewindable.)

Thanks!

So, since want to use the pipe twice, I wonder if I can use the piped data to discern what I want (in this case max string lengths), meanwhile piping to a child process, which I can then signal with my findings...

Nope, because (total guess, please comment) the child process would hold up the pipe while waiting for my signal, thus the OS would be buffering the pipe and I might hit my memory wall same as if I had just slurped the data in my parent process anyway.

Hmmm.  Sounds like I'm asking the impossible:

cat query.sql | dump_results --delim ',' | pivot_dump | col_width --var

where col_width is to make each column of data just wide enough to fit it's largest member:

select a,b,c,d,e,f from foo

  becomes

a,b,c,d,e,f
12,34,5432,23,56,45
23,,45,6,12,34
4445,34,,6,45,23

  becomes

a,12,23,4445
b,34,,34
c,5432,45,
d,23,6,6
e,56,12,45
f,45,34,23

  becomes

a  12    23  4445
b  34        34
c  5432  45
d  23    6   6
e  56    12  45
f  45    34  23

Thanks,
Phil
-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**