port to convert comma delimited file

Simon Barner barner at in.tum.de
Wed Mar 26 02:09:45 PST 2003


Hi,

> 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?

You will not need the ports collection.

All you need is the perl programming language, and that's in the base system
(at least, if you are running 4.x, for 5.x you will have to install a port
indeed).

Have a look at the 'split' function.
Your perl script will perform the following algorithm:

print ("<TABLE>");
Read the input file line-wise
   for each line, do the following
      print ("<TR>");
      split the line (with comma as separator) and put the result into an array
	  
	  for each component of the array (see the 'shift' function)
	     print ("<TD>");
		 now print the element
		 print ("</TD>");
		 
	  print ("</TR>");
	  
print ("</TABLE>");

There are lots of perl tutorials around the 'net, but if you perfer books, I'd
recommend "Lerning Perl" (Oreily), which I found very helpful.

Btw.: Some perl knowledge can never harm in a UN*X environment. Your task is an
ideal motivation to get to now this mighty language.

Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: Digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20030326/644a9b53/attachment-0001.bin


More information about the freebsd-questions mailing list