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
-
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.
-
I don't know.
-
here buddy: try using Perl:
#!/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!
-
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. :)
-
here, check it out, i recoded it for you! :)
#!/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.
-
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:
cat file.txt | sed 's/ /\n/g'
yay! this is fun!
-
thanks so much, you're amazing!
I'll let you know how it goes.
-
I still owe Trev some illegally downloaded books. I've got the time today, so maybe you'll get some today! OMGHAX!2131#!@#1
-
i luv you guys. i love pla. and today it's my birthday. 11-7-1980.
-
HAPPY BIRTHDAY TREVELYN! YOU'RE WASTING YOUR LIFE HERE JUST LIKE THE REST OF US~~~~ :nonsense:
-
HAPPY BIRTHDAY TREV! WE LOVE YOU TOO!
-
thanks! :D
-
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.
-
i luv you guys. i love pla. and today it's my birthday. 11-7-1980.
Did you get my letter yet?
-
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.
-
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!
-
i luv you guys. i love pla. and today it's my birthday. 11-7-1980.
Happy birthday, Trev!
<3
jenn
-
thanks! :)
-
c'mon linear, did it work for you or no??