PLA Forums

Other Stuff That Has Little To Do With PLA => General Discussions => Topic started by: linear on November 06, 2008, 03:38:36 PM

Title: code help because i'm a big stupid idiot.
Post by: linear on November 06, 2008, 03:38:36 PM
what's a quick and dirty way to render a set of data as a word doc?

or at least a page that when printed is 5(down)x2(across) blocks for printing data sets.

it can be perl, php, or javascript.
Title: Re: code help because i'm a big stupid idiot.
Post by: liife on November 07, 2008, 07:18:15 AM
I don't know.
Title: Re: code help because i'm a big stupid idiot.
Post by: trevelyn on November 07, 2008, 10:42:57 AM
here buddy:  try using Perl:

Quote
#!/usr/bin/perl
open (FILE, "file.txt");
@lines = <FILE>;
close (FILE);
chomp @lines;
print "$lines[0] $lines[1]\n";
print "$lines[2] $lines[3]\n";
print "$lines[4] $lines[5]\n";
print "$lines[6] $lines[7]\n";
print "$lines[8] $lines[9]\n";
print "\n";
print "$lines[10] $lines[11]\n";
print "$lines[12] $lines[13]\n";
# go on from there...
exit;

that's if the file you give it "file.txt" is line by line.  :)

Edit: jesus christ already with the red bold el oh el's.  I had to edit this whole damned post cos i used el oh el as the filehandle and el oh el dot tee ecks tee as the file!
Title: Re: code help because i'm a big stupid idiot.
Post by: trevelyn on November 07, 2008, 11:02:03 AM
yo, wait, i thought of two things.. If the file is HUGE you won't want to code the whole thing, so stick the block into a while loop. and the highest element of the set @lines would be $#lines.  Also, if the file is NOT line by line, just make it that way with sed using regexp's.  :)
Title: Re: code help because i'm a big stupid idiot.
Post by: trevelyn on November 07, 2008, 11:15:18 AM
here, check it out, i recoded it for you! :)

Quote
#!/usr/bin/perl
$n = 0;
open (FILE, "file.txt");
@lines = <FILE>;
close (FILE);
chomp @lines; $m = $#lines;
until ($n > $m) { print "$lines[$n]"; $n++; print " $lines[$n]\n"; $n++;
print "$lines[$n]"; $n++; print " $lines[$n]\n"; $n++;
print "$lines[$n]"; $n++; print " $lines[$n]\n"; $n++;
print "$lines[$n]"; $n++; print " $lines[$n]\n"; $n++;
print "$lines[$n]"; $n++; print " $lines[$n]\n"; $n++;
print "\n"; }
/me <-- just another perl hacker.
Title: Re: code help because i'm a big stupid idiot.
Post by: trevelyn on November 07, 2008, 11:20:11 AM
youre taking way too long to respond so i'll post a sed statement too, here is what you do if you wanna get rid of space in a file (to make it work with the above scripts:

Quote
cat file.txt | sed 's/ /\n/g'

yay! this is fun!
Title: Re: code help because i'm a big stupid idiot.
Post by: linear on November 07, 2008, 11:26:52 AM
thanks so much, you're amazing!

I'll let you know how it goes.
Title: Re: code help because i'm a big stupid idiot.
Post by: ApprenticePhreak on November 07, 2008, 11:33:27 AM
I still owe Trev some illegally downloaded books. I've got the time today, so maybe you'll get some today! OMGHAX!2131#!@#1
Title: Re: code help because i'm a big stupid idiot.
Post by: trevelyn on November 07, 2008, 11:52:11 AM
i luv you guys. i love pla.  and today it's my birthday. 11-7-1980.
Title: Re: code help because i'm a big stupid idiot.
Post by: ApprenticePhreak on November 07, 2008, 12:21:47 PM
HAPPY BIRTHDAY TREVELYN! YOU'RE WASTING YOUR LIFE HERE JUST LIKE THE REST OF US~~~~  :nonsense:
Title: Re: code help because i'm a big stupid idiot.
Post by: Nod on November 07, 2008, 01:14:46 PM
HAPPY BIRTHDAY TREV! WE LOVE YOU TOO!
Title: Re: code help because i'm a big stupid idiot.
Post by: trevelyn on November 07, 2008, 01:15:49 PM
thanks! :D
Title: Re: code help because i'm a big stupid idiot.
Post by: Nod on November 07, 2008, 01:17:18 PM
Can I mail you my phone and have you do all the neat stuff I want with it? I'll gladly send you a cookie.
Title: Re: code help because i'm a big stupid idiot.
Post by: murd0c on November 07, 2008, 01:25:41 PM
i luv you guys. i love pla.  and today it's my birthday. 11-7-1980.

Did you get my letter yet?
Title: Re: code help because i'm a big stupid idiot.
Post by: Nod on November 07, 2008, 01:29:49 PM
I WANT A LETTER FROM MURD0C! But I don't want him to have my address 'cause I'm afraid he'll find me and buttrape me.
Title: Re: code help because i'm a big stupid idiot.
Post by: trevelyn on November 07, 2008, 02:04:34 PM
i luv you guys. i love pla.  and today it's my birthday. 11-7-1980.

Did you get my letter yet?

yes, i havent seen you on AIM to thank you, That sticker means a lot to me.. more than you can imagine.  thanks Murd0c!
Title: Re: code help because i'm a big stupid idiot.
Post by: jx on November 07, 2008, 02:05:30 PM
i luv you guys. i love pla.  and today it's my birthday. 11-7-1980.

Happy birthday, Trev!

<3
jenn
Title: Re: code help because i'm a big stupid idiot.
Post by: trevelyn on November 07, 2008, 04:02:17 PM
thanks! :)
Title: Re: code help because i'm a big stupid idiot.
Post by: trevelyn on November 07, 2008, 08:40:48 PM
c'mon linear, did it work for you or no??