[CLUE-Tech] This should be simple...

David Willson DLWillson at TheGeek.NU
Fri Oct 25 15:22:53 MDT 2002


Y'know what really rocks?  Between Todd and Keith, I have four usable
progs, in all four of the languages we've covered or will be covering at
Fun-da-mentals.  Thank you, gentlemen!

Todd: You ~are~ ready for Wednesday, right?  :-)

David Willson
MCT, MCSE, Network+, A+, Linux Enthusiast
http://TheGeek.NU 


-----Original Message-----
From: clue-tech-admin at clue.denver.co.us
[mailto:clue-tech-admin at clue.denver.co.us] On Behalf Of Todd Williams
Sent: Thursday, October 24, 2002 11:50 PM
To: clue-tech at clue.denver.co.us
Subject: Re: [CLUE-Tech] This should be simple...


quick-n-dirty
place the following few lines of perl in a file:


#!/usr/bin/perl

while(chomp($myrecord=<>)) {
   @myfields = split(/,/, $myrecord);

   for $i ( 0 .. $#myfields ) {
     ($myfields[$i] =~ /^ +$/) && ($myfields[$i] = $oldfields[$i]);
   }
   print join(",", @myfields), "\n";
   @oldfields = @myfields;
}


invoke like:
$ flatten.pl < raw-report.csv



David Willson wrote:
> ... but it's not.  No, after almost two days of trying to RTFM, and
> side-streets galore, I just can't figure this out.  And I'm not often 
> getting answers here on CLUE-tech anymore, which could mean any of 
> several things, but I like to think it's that I'm coming up with 
> questions that can't be easily answered.  Whatever...  I'll get to the

> point.
> 
> I need a way to loop through the lines of a file.  I don't want the
> whole file in one shot, I want something like this:
> 
> joe = file.open(raw-report.csv);
> myRecord = joe.readNextLine();
> myFields[] = myRecord.parseOn(",");
> 
> While(!joe.EOF) {
>   myRecord = joe.readNextLine();
>   myFields[] = myRecord.parseOn(",");
> }
> 
> Why do I want this?  Because I have a file that is laid out like a
tree:
>   Willson, David, Lawrence
>          ,      , Timothy
>          , Katie, M.K.V.
>          , Evan , Patrick
>   Craft  , Chris, Micheal
> And I need it to be laid out 'flat', for lack of a better word:
>   Willson, David, Lawrence
>   Willson, David, Timothy
>   Willson, Katie, M.K.V.
>   Willson, Evan , Patrick
>   Craft  , Chris, Micheal
> 
> I need to convert all the implicit repeats into explicit/actual
> repeats.
> 
> So, how do I?  Anyone?  Anyone?  Bueller?

_______________________________________________
CLUE-Tech mailing list
CLUE-Tech at clue.techangle.com
http://clue.techangle.com/mailman/listinfo/clue-tech




More information about the clue-tech mailing list