Date: Wed, 26 Mar 2003 05:04:20 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Dru <dlavigne6@cogeco.ca> Cc: questions@freebsd.org Subject: Re: port to convert comma delimited file Message-ID: <20030326030420.GA16019@gothmog.gr> In-Reply-To: <20030325204410.D17599@dhcp-17-14.kico2.on.cogeco.ca> References: <20030325204410.D17599@dhcp-17-14.kico2.on.cogeco.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2003-03-25 20:51, Dru <dlavigne6@cogeco.ca> wrote: > I have a comma delimited file with approximately 7000 rows and 5 > columns. I have absolutely no database skills and and almost as > much HTML skill, yet I need to convert this file into an HTML > table. Is there something in the ports collection that will do this > for me, a sort of converter for dummies? Barring that, is there any > port that will do this, hopefully with docs so I can learn as I go? Someone mentioned Perl. Try the following little Perl snippet: #!/usr/bin/perl print "<TABLE>\n"; while (defined($line = <STDIN>)) { chomp $line; print "<TR><TD>" . join("</TD><TD>", split(/;/, $line)) . "</TD></TR>\n"; } print "</TABLE>\n"; Save this to a file called csv2html.pl and then run it like this: $ perl csv2html.pl < filename.csv > filename.html The power of Unix as an environment comes from the ability to write small, throw-away programs like this one, in one of the dozens of scripting languages that are usually available. Why hunt for a port to do something so simple[1] ? [1] For some definintion of `simple'.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030326030420.GA16019>